This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dennis Sweeney
Recipients Dennis Sweeney, Yonatan Goldschmidt, ammar2, steven.daprano
Date 2020-08-15.07:05:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1597475120.59.0.973566342873.issue41545@roundup.psfhosted.org>
In-reply-to
Content
This is exactly the motivation for context managers, no? I attached no_gc.py, which works when nested and should additionally be thread-safe. Usage:

from no_gc import no_gc

with no_gc():
    # collection disabled
    with no_gc():
        # collection is still disabled
    # collection is still disabled
# collection is finally re-enabled here
History
Date User Action Args
2020-08-15 07:05:20Dennis Sweeneysetrecipients: + Dennis Sweeney, steven.daprano, ammar2, Yonatan Goldschmidt
2020-08-15 07:05:20Dennis Sweeneysetmessageid: <1597475120.59.0.973566342873.issue41545@roundup.psfhosted.org>
2020-08-15 07:05:20Dennis Sweeneylinkissue41545 messages
2020-08-15 07:05:20Dennis Sweeneycreate