Linked Questions

1 vote
2 answers
3k views

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 ...
Patrick_Chong's user avatar
0 votes
2 answers
2k views

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(...
Bunny's user avatar
  • 372
1 vote
1 answer
769 views

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 ...
Hakan's user avatar
  • 329
339 votes
5 answers
395k views

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 ...
Claude's user avatar
  • 10.2k
212 votes
6 answers
118k views

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 ...
Mike N's user avatar
  • 6,865
16 votes
2 answers
19k views

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 ...
willir's user avatar
  • 669
2 votes
3 answers
7k views

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 ...
user1330734's user avatar
1 vote
1 answer
3k views

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 ...
luochen1990's user avatar
  • 3,905
1 vote
1 answer
1k views

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. ...
kav's user avatar
  • 717
0 votes
0 answers
77 views

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 ...
Zilicon's user avatar
  • 3,858