R. David Murray added the comment: In the first case, once the loop has run the task it no longer has a reference to it, and it gets GCed. The __del__ method of the task calls your exception handler. In the second case, you have a reference to it, so __del__ does not get called.
If you want the exception to be realized in the second case, you have to yield from it somewhere in your program. ---------- nosy: +r.david.murray resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28274> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com