Skip to content

Instantly share code, notes, and snippets.

@Nydhal
Created March 21, 2019 12:18
Show Gist options
  • Select an option

  • Save Nydhal/478b2027a385e7a9b7402a9e77b680f8 to your computer and use it in GitHub Desktop.

Select an option

Save Nydhal/478b2027a385e7a9b7402a9e77b680f8 to your computer and use it in GitHub Desktop.
import asyncio
async def FizzBuzz(i: int):
await asyncio.sleep(i)
print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or i)
async def SleepFizzBuzz(l,loop):
tasks = [loop.create_task(FizzBuzz(i)) for i in range(1,l+1)]
for t in tasks:
await t
async def main(loop):
await SleepFizzBuzz(30,loop)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment