Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import asyncio
  2.  
  3. async def special_function
  4. # does some work,
  5. # Passes control back to controller to run main_functions
  6. # if they are no longer waiting.
  7. asyncio.sleep(0.001)
  8.  
  9. async def handler():
  10. tasks = [task() for task in main_tasks]
  11.  
  12. # Adding the task that I want to run when all main_tasks are awaiting:
  13. tasks.append(special_function())
  14.  
  15. await asyncio.wait(tasks)
  16.  
  17. asyncio.get_event_loop().run_until_complete(handler())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement