Skip to content

Instantly share code, notes, and snippets.

@itdaniher
Created September 21, 2018 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itdaniher/b2b53884a18ac44a319bb544a169145e to your computer and use it in GitHub Desktop.
Save itdaniher/b2b53884a18ac44a319bb544a169145e to your computer and use it in GitHub Desktop.
πŸ˜‘
import asyncio
import sys
async def test():
1//0
loop = asyncio.get_event_loop()
def asyncio_handler(loop, context):
print("XXXX", "got", context)
def sys_handler(*args, **kwargs):
print("sync handler")
sys.excepthook = sys_handler
loop.set_exception_handler(asyncio_handler)
print('asyncio exception handler:', loop.get_exception_handler())
print('sys.excepthook', sys.excepthook)
task = loop.create_task(test())
loop.run_until_complete(task)
loop.run_until_complete(asyncio.sleep(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment