Coroutines and asyncio

See Typing async/await for the full detail on typing coroutines and asynchronous code.

  1. import asyncio
  2.  
  3. # A coroutine is typed like a normal function
  4. async def countdown35(tag: str, count: int) -> str:
  5. while count > 0:
  6. print('T-minus {} ({})'.format(count, tag))
  7. await asyncio.sleep(0.1)
  8. count -= 1
  9. return "Blastoff!"