Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import time
- loop = asyncio.get_event_loop()
- async def waiter():
- task1 = loop.create_task(cook('Pasta', 8))
- task2 = loop.create_task(cook('Cesar', 3))
- task3 = loop.create_task(cook('Chops', 16))
- await task1
- await task2
- await task3
- async def cook(order, time_to_prepare):
- print(f'New order: {order}')
- await asyncio.sleep(time_to_prepare)
- print(order, '- done')
- loop.run_until_complete(waiter())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement