Nick Coghlan <> added the comment:

If I recall the discussion correctly, it was:

1. That this was worth doing precisely because the naive approach is likely to 
be broken in the presence of multiple threads;
2. It was only worth doing either as a true global disable that accounted for 
multi-threading (e.g. backed by a counted semaphore or the functional 
equivalent), or else by making gc enable/disable status have a thread local 
toggle in addition to the global one (so the context manager can ensure "GC is 
off *in this thread*, regardless of the global status").

Either of those two options requires changes to the main GC machinery though, 
as otherwise you basically *can't* write a correct context manager for this use 
case, since a direct call to gc.enable() in another thread would always be 


Python tracker <>
Python-bugs-list mailing list

Reply via email to