Gregory P. Smith added the comment:

I believe Raymond is aware of the thread issue.  We discussed it.

If gc.disable() would return the previous state of the gc instead of None and 
an API to enable based on a passed in bool, both of which are written in C and 
executed with the GIL (or merely another lock protecting changing the gc state 
rather than the GIL) held and this Python would works with multiple threads all 
fighting to control the gc state:

@contextmanager
def gc_disabled():
  previous_enable_state = gc.disable()
  yield
  gc.set_enable(previous_enable_state)

But we don't need to modify gc.disable's return value or add a set_enable() if 
gc_disabled() itself is not implemented in Python.  That's up to the 
implementer.

----------

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

Reply via email to