Skip to content

Tag: python-asyncio

async_generator’ object is not iterable

I need to return a value in async function. I tried to use synchronous form of return: output: 0 [Finished in 204ms] But it just return value of the first loop, which is not expexted. So changed the code as below: output: TypeError: ‘async_generator’ object is not iterable by using async generator…

Grouping asynchronous functions to run

I have a code that outputs numbers from 1 to 10: Output: 1 2 3 4 5 6 7 8 9 10 It is noticeable that in the example above, 10 functions are simultaneously launched at once. How can I fix the code so that the number of concurrent launched functions main() is equal to count_group? That is, immediately the

add task to running loop and run until complete

I have a function called from an async function without await, and my function needs to call async functions. I can do this with asyncio.get_running_loop().create_task(sleep()) but the run_until_complete at the top level doesn’t run until the new task is complete. How do I get the event loop to run unti…