I would like to achieve the following using asyncio:
# Each iteration of this loop MUST last only 1 second while True: # Make an async request sleep(1) However, the only examples I've seen use some variation of
async def my_func(): loop = asyncio.get_event_loop() await loop.run_in_executor(None, requests.get, 'http://www.google.com') loop = asyncio.get_event_loop() loop.run_until_complete(my_func()) But run_until_complete is blocking! Using run_until_complete in each iteration of my while loop would cause the loop to block.
I've spent the last couple of hours trying to figure out how to correctly run a non-blocking task (defined with async def) without success. I must be missing something obvious, because something as simple as this should surely be simple. How can I achieve what I have described?