Asyncio RuntimeError: Event Loop is Closed

前端 未结 2 2006
灰色年华
灰色年华 2020-12-18 19:51

I\'m trying to make a bunch of requests (~1000) using Asyncio and the aiohttp library, but I am running into a problem that I can\'t find much info on.

When I run th

2条回答
  •  清酒与你
    2020-12-18 20:05

    The bug is filed as https://github.com/python/asyncio/issues/258 Stay tuned.

    As quick workaround I suggest using custom executor, e.g.

    loop = asyncio.get_event_loop()
    executor = concurrent.futures.ThreadPoolExecutor(5)
    loop.set_default_executor(executor)
    

    Before finishing your program please do

    executor.shutdown(wait=True)
    loop.close()
    

提交回复
热议问题