Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import asyncio
  2.  
  3. async def FizzBuzz(i: int):
  4. await asyncio.sleep(i)
  5. print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or i)
  6.  
  7. async def SleepFizzBuzz(l,loop):
  8. tasks = [loop.create_task(FizzBuzz(i)) for i in range(1,l+1)]
  9. for t in tasks:
  10. await t
  11.  
  12. async def main(loop):
  13. await SleepFizzBuzz(30,loop)
  14.  
  15. if __name__ == '__main__':
  16. loop = asyncio.get_event_loop()
  17. loop.run_until_complete(main(loop))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement