Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # encoding=utf-8
- import asyncio
- from utility import time_me, hello
- from run_ import run, create_task
- """
- filename: basic18.py
- description: call back
- License: GPL V2
- Author: 天使de眼睛
- 除特别声明,所有代码均是 python3.6 在 iOS 环境下编写测试。
- """
- asyncio.run = run
- asyncio.create_task = create_task
- def call_back(task):
- print('in callback:', task.result())
- @time_me
- async def main():
- tasks = [asyncio.create_task(hello(1, 'Kitty')), asyncio.create_task(hello(2, 'Doggy')) ]
- for task in tasks:
- task.add_done_callback(call_back)
- await task
- if __name__ == '__main__':
- asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement