Message382975
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.) |
|
Date |
User |
Action |
Args |
2020-12-14 10:36:21 | natano | set | recipients:
+ natano, asvetlov, yselivanov |
2020-12-14 10:36:21 | natano | set | messageid: <1607942181.31.0.646688674125.issue42636@roundup.psfhosted.org> |
2020-12-14 10:36:21 | natano | link | issue42636 messages |
2020-12-14 10:36:20 | natano | create | |
|