Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- async def special_function
- # does some work,
- # Passes control back to controller to run main_functions
- # if they are no longer waiting.
- asyncio.sleep(0.001)
- async def handler():
- tasks = [task() for task in main_tasks]
- # Adding the task that I want to run when all main_tasks are awaiting:
- tasks.append(special_function())
- await asyncio.wait(tasks)
- asyncio.get_event_loop().run_until_complete(handler())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement