Skip to content
Advertisement

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 I am facing with this error. How can

asyncio.gather not executing tasks when caller function requests input from STDIN?

In the following contrived example I am attempting to get input from STDIN and execute a list of coroutine tasks concurrently using asyncio.gather based on the input from STDIN.: However when executing the above code the output does not contain the desired output when the corresponding option is entered. Input ‘1’ from STDIN should print to STDOUT: Input ‘2’ from

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 until the new task is complete? I can’t make my function

Use the same websocket connection in multiple asynchronous loops (Python)

I am running two loops asynchronously, and want both to have access to the same websocket connection. One function periodic_fetch() fetches some data periodically (every 60 seconds) and sends a message to the websocket if a condition is met. The other retrieve_websocket() receives messages from the websocket and perform some action if a condition is met. As of now, I

Advertisement