I’ve got three different generators, which yields data from the web. Therefore, each iteration may take a while until it’s done.
I want to mix the calls to the generators, and thought about roundrobin (Found here).
The problem is that every call is blocked until it’s done.
Is there a way to loop through all the generators at the same time, without blocking?
You can do this with the
iter()method on myThreadPoolclass.pool.iter()yields threaded function return values until all of the decorated+called functions finish executing. Decorate all of your async functions, call them, then loop throughpool.iter()to catch the values as they happen.Example: