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
136
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

Forum statistics

Threads
474,037
Messages
2,570,371
Members
47,013
Latest member
JewellChes

Latest Threads

Top