[issue31356] Add context manager to temporarily disable GC

Serhiy Storchaka report at bugs.python.org
Mon Feb 5 01:29:02 EST 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

1. The used approach was broken in the presence of multiple threads too. It didn't guarantee even that GC will be disabled in the next line.

2. What is a sense of disabling GC in a single thread? Objects in Python are not thread local, they are accessible from all threads, and collecting garbage in one thread affects other threads.

For truly disabling GC globally you need to use a counted semaphore or other synchronization primitives, and this can be implemented at Python level. But what are use cases for this context manager? Isn't naive approach enough?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31356>
_______________________________________


More information about the Python-bugs-list mailing list