[Python-checkins] cpython: add a contextmanager to disable the gc
benjamin.peterson
python-checkins at python.org
Thu Jul 14 19:43:40 CEST 2011
http://hg.python.org/cpython/rev/527a52d682f6
changeset: 71331:527a52d682f6
user: Benjamin Peterson <benjamin at python.org>
date: Thu Jul 14 12:48:01 2011 -0500
summary:
add a contextmanager to disable the gc
files:
Lib/test/support.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -1005,6 +1005,16 @@
gc.collect()
gc.collect()
+ at contextlib.contextmanager
+def disable_gc():
+ have_gc = gc.isenabled()
+ gc.disable()
+ try:
+ yield
+ finally:
+ if have_gc:
+ gc.enable()
+
def python_is_optimized():
"""Find if Python was built with optimizations."""
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list