[New-bugs-announce] [issue35751] traceback.clear_frames manages to deadlock a background task

Тарас Войнаровський report at bugs.python.org
Wed Jan 16 05:34:07 EST 2019

New submission from Тарас Войнаровський <voyn1991 at gmail.com>:

My use case:
I have a background task, say called "coordination". In that task, I want to catch any errors and push those to the user waiting in the main task and only continue running the background coroutine after the user manually resolves the exception. 

When testing the behaviour with ``unittest.Case`` and using ``assertRaises`` to catch the exception, the background coroutine manages to just freeze. I have narrowed it down to ``traceback.clear_frames`` in ``assertRaises`` that causes a GeneratorExit in the background coroutine.

I believe this issue is a duplicate to https://bugs.python.org/issue29211, but wanted to provide another actual use case where it can pop up. Also even if the generator raises a GeneratorExit, why did the background thread freeze is still a mystery to me.

Script to reproduce in my case is attached.

components: asyncio
files: test_async_deadlock.py
messages: 333759
nosy: asvetlov, yselivanov, Тарас Войнаровський
priority: normal
severity: normal
status: open
title: traceback.clear_frames manages to deadlock a background task
type: behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48059/test_async_deadlock.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list