Dennis Sweeney <sweeney.dennis...@gmail.com> added the comment:
https://bugs.python.org/issue41545 is a duplicate of this. In that report, there's an example of something that can go wrong with the save-a-boolean-per-context-manager approach even when threads are not used, but when concurrent generators are used, like def gen(): with gc_disabled(): yield 1 yield 2 yield 3 a = gen() b = gen() next(a) # disable gc next(b) list(a) # this re-enableds the gc next(b) # gc is enabled but shouldn't be. A counter for "number of times disabled" may be a better approach. ---------- nosy: +Dennis Sweeney _______________________________________ 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