async_def.py 229 B

12345678910111213141516
  1. # test async def
  2. def dec(f):
  3. print('decorator')
  4. return f
  5. # test definition with a decorator
  6. @dec
  7. async def foo():
  8. print('foo')
  9. coro = foo()
  10. try:
  11. coro.send(None)
  12. except StopIteration:
  13. print('StopIteration')