Python test.support.disable_gc() Examples
The following are 20
code examples of test.support.disable_gc().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test.support
, or try the search function
.
Example #1
Source File: test_weakref.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def collect_in_thread(period=0.0001): """ Ensure GC collections happen in a different thread, at a high frequency. """ threading = support.import_module('threading') please_stop = False def collect(): while not please_stop: time.sleep(period) gc.collect() with support.disable_gc(): t = threading.Thread(target=collect) t.start() try: yield finally: please_stop = True t.join()
Example #2
Source File: test_case.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())
Example #3
Source File: test_yield_from.py From android_universal with MIT License | 5 votes |
def test_close_with_cleared_frame(self): # See issue #17669. # # Create a stack of generators: outer() delegating to inner() # delegating to innermost(). The key point is that the instance of # inner is created first: this ensures that its frame appears before # the instance of outer in the GC linked list. # # At the gc.collect call: # - frame_clear is called on the inner_gen frame. # - gen_dealloc is called on the outer_gen generator (the only # reference is in the frame's locals). # - gen_close is called on the outer_gen generator. # - gen_close_iter is called to close the inner_gen generator, which # in turn calls gen_close, and gen_yf. # # Previously, gen_yf would crash since inner_gen's frame had been # cleared (and in particular f_stacktop was NULL). def innermost(): yield def inner(): outer_gen = yield yield from innermost() def outer(): inner_gen = yield yield from inner_gen with disable_gc(): inner_gen = inner() outer_gen = outer() outer_gen.send(None) outer_gen.send(inner_gen) outer_gen.send(outer_gen) del outer_gen del inner_gen gc_collect()
Example #4
Source File: test_frame.py From android_universal with MIT License | 5 votes |
def test_clear_refcycles(self): # .clear() doesn't leave any refcycle behind with support.disable_gc(): class C: pass c = C() wr = weakref.ref(c) exc = self.outer(c=c) del c self.assertIsNot(None, wr()) self.clear_traceback_frames(exc.__traceback__) self.assertIs(None, wr())
Example #5
Source File: test_finalization.py From android_universal with MIT License | 5 votes |
def test(cls): """ A context manager to use around all finalization tests. """ with support.disable_gc(): cls.del_calls.clear() cls.tp_del_calls.clear() NonGCSimpleBase._cleaning = False try: yield if cls.errors: raise cls.errors[0] finally: NonGCSimpleBase._cleaning = True cls._cleanup()
Example #6
Source File: test_case.py From android_universal with MIT License | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())
Example #7
Source File: test_case.py From odoo13-x64 with GNU General Public License v3.0 | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())
Example #8
Source File: test_pep380.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_close_with_cleared_frame(self): # See issue #17669. # # Create a stack of generators: outer() delegating to inner() # delegating to innermost(). The key point is that the instance of # inner is created first: this ensures that its frame appears before # the instance of outer in the GC linked list. # # At the gc.collect call: # - frame_clear is called on the inner_gen frame. # - gen_dealloc is called on the outer_gen generator (the only # reference is in the frame's locals). # - gen_close is called on the outer_gen generator. # - gen_close_iter is called to close the inner_gen generator, which # in turn calls gen_close, and gen_yf. # # Previously, gen_yf would crash since inner_gen's frame had been # cleared (and in particular f_stacktop was NULL). def innermost(): yield def inner(): outer_gen = yield yield from innermost() def outer(): inner_gen = yield yield from inner_gen with disable_gc(): inner_gen = inner() outer_gen = outer() outer_gen.send(None) outer_gen.send(inner_gen) outer_gen.send(outer_gen) del outer_gen del inner_gen gc_collect()
Example #9
Source File: test_frame.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_clear_refcycles(self): # .clear() doesn't leave any refcycle behind with support.disable_gc(): class C: pass c = C() wr = weakref.ref(c) exc = self.outer(c=c) del c self.assertIsNot(None, wr()) self.clear_traceback_frames(exc.__traceback__) self.assertIs(None, wr())
Example #10
Source File: test_finalization.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test(cls): """ A context manager to use around all finalization tests. """ with support.disable_gc(): cls.del_calls.clear() cls.tp_del_calls.clear() NonGCSimpleBase._cleaning = False try: yield if cls.errors: raise cls.errors[0] finally: NonGCSimpleBase._cleaning = True cls._cleanup()
Example #11
Source File: test_case.py From jawfish with MIT License | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())
Example #12
Source File: test_pep380.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_close_with_cleared_frame(self): # See issue #17669. # # Create a stack of generators: outer() delegating to inner() # delegating to innermost(). The key point is that the instance of # inner is created first: this ensures that its frame appears before # the instance of outer in the GC linked list. # # At the gc.collect call: # - frame_clear is called on the inner_gen frame. # - gen_dealloc is called on the outer_gen generator (the only # reference is in the frame's locals). # - gen_close is called on the outer_gen generator. # - gen_close_iter is called to close the inner_gen generator, which # in turn calls gen_close, and gen_yf. # # Previously, gen_yf would crash since inner_gen's frame had been # cleared (and in particular f_stacktop was NULL). def innermost(): yield def inner(): outer_gen = yield yield from innermost() def outer(): inner_gen = yield yield from inner_gen with disable_gc(): inner_gen = inner() outer_gen = outer() outer_gen.send(None) outer_gen.send(inner_gen) outer_gen.send(outer_gen) del outer_gen del inner_gen gc_collect()
Example #13
Source File: test_frame.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_clear_refcycles(self): # .clear() doesn't leave any refcycle behind with support.disable_gc(): class C: pass c = C() wr = weakref.ref(c) exc = self.outer(c=c) del c self.assertIsNot(None, wr()) self.clear_traceback_frames(exc.__traceback__) self.assertIs(None, wr())
Example #14
Source File: test_finalization.py From ironpython3 with Apache License 2.0 | 5 votes |
def test(cls): """ A context manager to use around all finalization tests. """ with support.disable_gc(): cls.del_calls.clear() cls.tp_del_calls.clear() NonGCSimpleBase._cleaning = False try: yield if cls.errors: raise cls.errors[0] finally: NonGCSimpleBase._cleaning = True cls._cleanup()
Example #15
Source File: test_case.py From ironpython3 with Apache License 2.0 | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())
Example #16
Source File: test_case.py From Imogen with MIT License | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())
Example #17
Source File: test_pep380.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_close_with_cleared_frame(self): # See issue #17669. # # Create a stack of generators: outer() delegating to inner() # delegating to innermost(). The key point is that the instance of # inner is created first: this ensures that its frame appears before # the instance of outer in the GC linked list. # # At the gc.collect call: # - frame_clear is called on the inner_gen frame. # - gen_dealloc is called on the outer_gen generator (the only # reference is in the frame's locals). # - gen_close is called on the outer_gen generator. # - gen_close_iter is called to close the inner_gen generator, which # in turn calls gen_close, and gen_yf. # # Previously, gen_yf would crash since inner_gen's frame had been # cleared (and in particular f_stacktop was NULL). def innermost(): yield def inner(): outer_gen = yield yield from innermost() def outer(): inner_gen = yield yield from inner_gen with disable_gc(): inner_gen = inner() outer_gen = outer() outer_gen.send(None) outer_gen.send(inner_gen) outer_gen.send(outer_gen) del outer_gen del inner_gen gc_collect()
Example #18
Source File: test_frame.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_clear_refcycles(self): # .clear() doesn't leave any refcycle behind with support.disable_gc(): class C: pass c = C() wr = weakref.ref(c) exc = self.outer(c=c) del c self.assertIsNot(None, wr()) self.clear_traceback_frames(exc.__traceback__) self.assertIs(None, wr())
Example #19
Source File: test_finalization.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test(cls): """ A context manager to use around all finalization tests. """ with support.disable_gc(): cls.del_calls.clear() cls.tp_del_calls.clear() NonGCSimpleBase._cleaning = False try: yield if cls.errors: raise cls.errors[0] finally: NonGCSimpleBase._cleaning = True cls._cleanup()
Example #20
Source File: test_case.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def testNoCycles(self): case = unittest.TestCase() wr = weakref.ref(case) with support.disable_gc(): del case self.assertFalse(wr())