"Runtime error event loop already running" during asyncio

868 Views Asked by At

I am trying out some asyncio examples found on the web: Proxybroker example

When I run this first example:

"""Find and show 10 working HTTP(S) proxies."""

import asyncio
from proxybroker import Broker

async def show(proxies):
    while True:
        proxy = await proxies.get()
        if proxy is None: break
        print('Found proxy: %s' % proxy)

proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(
    broker.find(types=['HTTP', 'HTTPS'], limit=10),
    show(proxies))

loop = asyncio.get_event_loop()
loop.run_until_complete(tasks)

I get the error:

RuntimeError: This event loop is already running

But the loop completes as expected. I'm new to concurrent code so any explanation / pseudo code of what is occurring would be appreciated.

1

There are 1 best solutions below

1
Kr.98 On BEST ANSWER

I install this package,and run it passed, no error occured,are use a ide? try to run it on cli,or move it another directory