This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients gvanrossum, jinty, r.david.murray, vstinner, yselivanov
Date 2015-10-27.14:59:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445957987.82.0.107321157913.issue25489@psf.upfronthosting.co.za>
In-reply-to
Content
Ah, I misunderstood your report, because I didn't actually run the example.  The exception is being ignored because it is raised during a __del__ method execution.  This has nothing to do with set_exception_handler.  And in fact if you raise sys.exit in an excepthook handler it is ignored completely, so the cases are parallel in that sense.  Interestingly, if you replace your Exception in boom with sys.exit, your sys.exit in the handler actually works, because in that case the handler isn't getting called from the Task __del__.

I don't think there's a bug in python here, I think the bug is in your program.  You aren't yielding from the task, so the exception from boom only gets dealt with during Task finalization.  I find this to be the most confusing part of asyncio programming, myself.  I don't know why the handler doesn't get called just from creating the Task and running the loop. I often end up writing wrapper functions that yield from a function that does the work inside a try/except, and/or yield from the task in a 'wait_closed' method.

Maybe someone with more asyncio inside knowledge will be able to clear this up, and we can figure out a doc improvement.
I suspect we need a "best practices" document about this...
History
Date User Action Args
2015-10-27 14:59:47r.david.murraysetrecipients: + r.david.murray, gvanrossum, vstinner, yselivanov, jinty
2015-10-27 14:59:47r.david.murraysetmessageid: <1445957987.82.0.107321157913.issue25489@psf.upfronthosting.co.za>
2015-10-27 14:59:47r.david.murraylinkissue25489 messages
2015-10-27 14:59:47r.david.murraycreate