From 31f4beb15e959e818947db3297ac639bc2afc067 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 14 Jul 2011 12:48:01 -0500 Subject: add a contextmanager to disable the gc --- Lib/test/support.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/support.py b/Lib/test/support.py index ba53ab9..64864de 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -1005,6 +1005,16 @@ def gc_collect(): gc.collect() gc.collect() +@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.""" -- cgit v0.12