Skip to content

Instantly share code, notes, and snippets.

@mukesh14149
Created October 4, 2020 16:35
import asyncio
async def some_async_task():
await asyncio.sleep(4)
return "result from some_async_task()"
async def some_async_task2():
await asyncio.sleep(2)
raise "Some exception"
async def main():
result = await asyncio.gather(some_async_task(), some_async_task2(), return_exceptions=True)
print(result)
asyncio.run(main())
"""Output:
['result from some_async_task()', TypeError('exceptions must derive from BaseException')]
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment