Asyncio RuntimeError: Event Loop is Closed

前端 未结 2 2007
灰色年华
灰色年华 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:06

    You're right, loop.getaddrinfo uses a ThreadPoolExecutor to run socket.getaddrinfo in a thread.

    You're using asyncio.wait_for with a timeout, which means res = yield from asyncio.wait_for... will raise a asyncio.TimeoutError after 4 seconds. Then the get_status coroutines return None and the loop stops. If a job finishes after that, it will try to schedule a callback in the event loop and raises an exception since it is already closed.

提交回复
热议问题