New submission from Martin Natano <natano+pythonb...@natano.net>:

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.)

----------
components: asyncio
files: trigger-warning.py
messages: 382975
nosy: asvetlov, natano, yselivanov
priority: normal
severity: normal
status: open
title: shielded task exception never retrieved when outer task cancelled
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file49679/trigger-warning.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42636>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to