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 natano
Recipients asvetlov, natano, yselivanov
Date 2020-12-14.10:36:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607942181.31.0.646688674125.issue42636@roundup.psfhosted.org>
In-reply-to
Content
A task created with asyncio.shield() never retrieves the task exception, which results in a log message being generated. See the attached script for a minimal example. Output looks something like this:

<snip>
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<some_coroutine() done, defined at /Users/natano/python-bug/trigger-warning.py:4> exception=Exception('foo')>
Traceback (most recent call last):
  File "/Users/natano/python-bug/trigger-warning.py", line 6, in some_coroutine
    raise Exception('foo')
Exception: foo
</snip>

I believe this behaviour is not intended and is an unintended side-effect of commit b35acc5b3a0148c5fd4462968b310fb436726d5a (https://github.com/python/cpython/commit/b35acc5b3a0148c5fd4462968b310fb436726d5a). The _inner_done_callback has has code to retrieve the exception when the outer task was cancelled, but since that commit the _inner_done_callback is not called anymore when the outer task was cancelled.


(Tested with 3.8, 3.9 and 3.10. I don't have a python 3.7 version available for testing, but I think this issue also affects 3.7.)
History
Date User Action Args
2020-12-14 10:36:21natanosetrecipients: + natano, asvetlov, yselivanov
2020-12-14 10:36:21natanosetmessageid: <1607942181.31.0.646688674125.issue42636@roundup.psfhosted.org>
2020-12-14 10:36:21natanolinkissue42636 messages
2020-12-14 10:36:20natanocreate