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 hello, time_me, StdErrRedirect
- from run_ import run, create_task
- """
- filename: basic9.py
- description: gather with exception
- if return_exeptions is set to False, stack will still display. (use StdErrRedirect)
- License: GPL V2
- Author: 天使de眼睛
- 除特别声明,所有代码均是 python3.6 在 iOS 环境下编写测试。
- """
- asyncio.run = run
- asyncio.create_task = create_task
- async def gather_tasks():
- return await asyncio.gather(hello(2, 'Kitty', raise_exception=True), hello(1, 'Doggy'))
- @time_me
- def main():
- try:
- with StdErrRedirect():
- result = asyncio.run(gather_tasks())
- except ValueError as e:
- print("Kitty has exception:", e)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement