Hi,

2014-02-06 17:53 GMT+01:00 Yury Selivanov <[email protected]>:
> I'm proposing a strawman design for having a user definable event loop
> handler for unhandled exceptions.

With my short experience of asyncio, I can say that it's a pain to
reconnect an "unhandled exception" to the future and the original
source code.

>   - "loop.set_exception_handler(callback)"
>     Sets 'callback' as a new unhandled error handler for the event loop
>     'loop'. The signature of callback should be '(loop, exception, context)'

... so it would be nice to give something to retrieve the source of
the exception. The minimum would be the future, task, or handle
object. The new parameter may be None if it doesn't apply.

I don't know why what's the best option to recover the original source
code from a task. An option is to use tracemalloc to get the traceback
where a task has been created. Another option is to always save the
traceback where a future has been created, directly in the future.
That's why I'm in favor of a "debug mode" for asyncio, to record the
traceback in debug mode, but don't record it in production to not add
any overhead.

The same problem applies from callbacks (handles, call_soon/call_at/etc.).

Victor

Reply via email to