Help with asyncio program freezing during requests

It could be that the one worker that got started hit an exception, and your script hung because you were still awaiting queue.join(), which was never going to happen because there were no active workers anymore. You could do something like:

# after the task creation loop
tasks.append(asyncio.create_task(queue.join())
done, not_done = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
if queue.empty():
    # all done, clean up
    for task in not_done:
        task.cancel()
else:
    # a worker must have errored out, raise the exception
    for task in done:
        task.result()

That should at least tell if if and how a worker is going wrong :slight_smile: