How do I wait for a coroutine to finish?

Joined
May 18, 2023
Messages
1
Reaction score
0
I have a list of coroutines, I put them in a queue. At some point, someone else will run them. I want to wait for a specific sublist of the coroutines to finish

Code:
coro_list = [coro1(), coro2(), ...]
queue = asyncio.Queue()
for c in coro_list:
    queue.put_nowait(c)

# someone else will read from the queue and await the coroutines...

# here, I want to wait, for example, only for coro_list[2:6] to finish

# ...
 
Joined
Sep 4, 2022
Messages
128
Reaction score
16
Threads and Tasks will help you to achieve.
With a better handle about the coroutines.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top