STINNER Victor <vstin...@python.org> added the comment:

There are different ways to fix this issue:

* (A) Rewrite threading.enumerate() in C with code which cannot trigger a GC 
collection
* (B) Disable temporarily the GC
* (C) Use a reentrant lock (PR 26727)

(A) The problem is that functions other than threading.enumerate() 
also rely on this lock, like threading.active_count(). I would prefer to not 
have to rewrite "half" of threading.py in C. Using a RLock is less intrusive.

(B) This is a simple and reliable option. But gc.disable() is process-wide: it 
affects all Python threads, and so it might have surprising side effects. Some 
code might rely on the current exact GC behavior. I would prefer to not disable 
the GC temporarily.

----------

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

Reply via email to