Linked Questions
10 questions linked to/from When using asyncio, how do you allow all running tasks to finish before shutting down the event loop
1 vote
2 answers
3k views
Why does my asynchronous function not complete all execution of its code? [duplicate]
I am just starting to learn about asynchronous programming, in particular the async and await syntax and usage of the asyncio module. My question is regarding the output of the following code: import ...
0 votes
2 answers
2k views
python asyncio.create_task tasks exiting earlier than expected? [duplicate]
I have the following code: import asyncio async def myfunc(i): print("hello", i) await asyncio.sleep(i) print("world", i) async def main(): asyncio.create_task(...
1 vote
1 answer
769 views
Asyncio.sleep blocking the rest of the function [duplicate]
Function cant pass to next line because of asyncio.sleep. There is rest of the code but i will share just 3 lines. It explains everything. Console doesnt print 0 to console. If i move print(0) above ...
339 votes
5 answers
395k views
asyncio.gather vs asyncio.wait (vs asyncio.TaskGroup)
asyncio.gather and asyncio.wait seem to have similar uses: I have a bunch of async things that I want to execute/wait for (not necessarily waiting for one to finish before the next one starts). Since ...
212 votes
6 answers
118k views
"Fire and forget" python async/await
Sometimes there is some non-critical asynchronous operation that needs to happen but I don't want to wait for it to complete. In Tornado's coroutine implementation you can "fire & forget" an ...
16 votes
2 answers
19k views
Python3 asyncio "Task was destroyed but it is pending" with some specific condition
Here is simplified code, which uses python3 coroutine and sets handler for SIGING and SIGTERM signals for stopping job properly: #!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse import ...
2 votes
3 answers
7k views
Start asyncio event loop in separate thread and consume queue items
I am writing a Python program that run tasks taken from a queue concurrently, to learn asyncio. Items will be put onto a queue by interacting with a main thread (within REPL). Whenever a task is put ...
1 vote
1 answer
3k views
asyncio.get_event_loop() fails when following asyncio.run()
I'm trying to find a solution to call async function in a Synchronous context. And following is my references: Python call callback after async function is done When using asyncio, how do you allow ...
1 vote
1 answer
1k views
Python asyncio gather does not exit after task complete
I have a coroutine foo1 from which I use asyncio.create_task() to call another coroutine foo2. As expected, foo1 finishes running and does not wait for the task to complete because there is no await. ...
0 votes
0 answers
77 views
send async requests during long worker operation
I have a situation where I have a processing function that can take a lot of time to run. This function takes a progress observer as an argument and notifies the observer about advancement. I would ...