[issue14976] queue.Queue() is not reentrant, so signals and GC can cause deadlocks

Itamar Turner-Trauring report at bugs.python.org
Sun Apr 16 16:44:34 EDT 2017


Itamar Turner-Trauring added the comment:

This bug was closed on the basis that signals + threads don't interact well. Which is a good point.

Unfortunately this bug can happen in cases that have nothing to do with signals. If you look at the title and some of the comments it also happens as a result of garbage collection: in `__del__` methods and weakref callbacks.

Specifically, garbage collection can happen on any bytecode boundary and cause reentrancy problems with Queue.

The attached file is an attempt to demonstrate this: it runs and runs until GC happens and then deadlocks for me (on Python 3.6). I.e. it prints GC! and after that no further output is printed and no CPU usage reported.

Please re-open this bug: if you don't want to fix signal case that's fine, but the GC case is still an issue.

----------
versions: +Python 3.5, Python 3.6
Added file: http://bugs.python.org/file46806/queuebug2.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14976>
_______________________________________


More information about the Python-bugs-list mailing list