Python gc.get_debug() Examples
The following are 30
code examples of gc.get_debug().
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
gc
, or try the search function
.
Example #1
Source File: test_gc.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests, GCCallbackTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print("restoring automatic collection") # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #2
Source File: test_gc.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_main(): enabled = gc.isenabled() try: gc.disable() assert not gc.isenabled() except NotImplementedError: pass debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #3
Source File: test_gc.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #4
Source File: test_gc.py From medicare-demo with Apache License 2.0 | 6 votes |
def test(): if verbose: print "disabling automatic collection" enabled = gc.isenabled() gc.disable() verify(not gc.isenabled()) debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: test_all() finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() verify(gc.isenabled()) if not enabled: gc.disable()
Example #5
Source File: test_gc.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_saveall(): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() vereq(gc.garbage, []) # if this fails, someone else created immortal trash L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) vereq(len(gc.garbage), 1) obj = gc.garbage.pop() vereq(id(obj), id_L)
Example #6
Source File: test_gc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests, GCCallbackTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print("restoring automatic collection") # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #7
Source File: test_gc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #8
Source File: test_gc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #9
Source File: test_gc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #10
Source File: garbage_monitor.py From scalyr-agent-2 with Apache License 2.0 | 6 votes |
def run(self): # get the current debug flags self._old_debug_flags = gc.get_debug() if self._monitor_all_unreachable: # and set the new ones we are interested in gc.set_debug(gc.DEBUG_SAVEALL) # Output some log information here so we can tell from the logs when the garbage monitor has been reloaded self._logger.info( "Starting garbage monitor. Outputting max %d types" % self._max_type_dump ) if len(self._object_dump_types): self._logger.info( "\tDumping %d objects of type(s) %s" % (self._max_object_dump, six.text_type(self._object_dump_types)) ) else: self._logger.info("\tNot dumping individual objects.") ScalyrMonitor.run(self)
Example #11
Source File: test_gc.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests, GCCallbackTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print("restoring automatic collection") # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #12
Source File: test_gc.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #13
Source File: test_gc.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #14
Source File: test_gc.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #15
Source File: test_gc.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #16
Source File: test_gc.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #17
Source File: test_gc.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_main(): enabled = gc.isenabled() try: gc.disable() assert not gc.isenabled() except NotImplementedError: pass debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #18
Source File: test_gc.py From oss-ftp with MIT License | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #19
Source File: test_gc.py From BinderFilter with MIT License | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #20
Source File: test_gc.py From oss-ftp with MIT License | 6 votes |
def test_saveall(self): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. # First make sure we don't save away other stuff that just happens to # be waiting for collection. gc.collect() # if this fails, someone else created immortal trash self.assertEqual(gc.garbage, []) L = [] L.append(L) id_L = id(L) debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) del L gc.collect() gc.set_debug(debug) self.assertEqual(len(gc.garbage), 1) obj = gc.garbage.pop() self.assertEqual(id(obj), id_L)
Example #21
Source File: test_gc.py From BinderFilter with MIT License | 6 votes |
def test_main(): enabled = gc.isenabled() gc.disable() assert not gc.isenabled() debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak try: gc.collect() # Delete 2nd generation garbage run_unittest(GCTests, GCTogglingTests) finally: gc.set_debug(debug) # test gc.enable() even if GC is disabled by default if verbose: print "restoring automatic collection" # make sure to always test gc.enable() gc.enable() assert gc.isenabled() if not enabled: gc.disable()
Example #22
Source File: test_gc.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_000_get_debug(self): """get_debug should return 0 if set_debug has not been used""" self.assertEqual(gc.get_debug(), 0)
Example #23
Source File: test_gc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_000_get_debug(self): """get_debug should return 0 if set_debug has not been used""" self.assertEqual(gc.get_debug(), 0)
Example #24
Source File: test_gc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_setdebug(self): if is_cli: for debug in debug_list: self.assertRaises(NotImplementedError, gc.set_debug,debug) self.assertEqual(0,gc.get_debug()) else: for debug in debug_list: gc.set_debug(debug) self.assertEqual(debug,gc.get_debug())
Example #25
Source File: test_gc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def setUp(self): # Save gc state and disable it. self.enabled = gc.isenabled() gc.disable() self.debug = gc.get_debug() gc.set_debug(0) gc.callbacks.append(self.cb1) gc.callbacks.append(self.cb2) self.othergarbage = []
Example #26
Source File: test_gc.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_get_debug(self): state = [0,gc.DEBUG_STATS,gc.DEBUG_COLLECTABLE,gc.DEBUG_UNCOLLECTABLE,gc.DEBUG_INSTANCES,gc.DEBUG_OBJECTS,gc.DEBUG_SAVEALL,gc.DEBUG_LEAK] result = gc.get_debug() if result not in state: self.fail("Returned value of getdebug method is not valid value:" + str(result))
Example #27
Source File: test_gc.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_setdebug(self): if is_cli: for debug in debug_list: self.assertRaises(NotImplementedError, gc.set_debug,debug) self.assertEqual(0,gc.get_debug()) else: for debug in debug_list: gc.set_debug(debug) self.assertEqual(debug,gc.get_debug()) gc.set_debug(0)
Example #28
Source File: test_gc.py From ironpython3 with Apache License 2.0 | 5 votes |
def setUp(self): # Save gc state and disable it. self.enabled = gc.isenabled() gc.disable() self.debug = gc.get_debug() gc.set_debug(0) gc.callbacks.append(self.cb1) gc.callbacks.append(self.cb2) self.othergarbage = []
Example #29
Source File: test_gc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def setUp(self): # Save gc state and disable it. self.enabled = gc.isenabled() gc.disable() self.debug = gc.get_debug() gc.set_debug(0) gc.callbacks.append(self.cb1) gc.callbacks.append(self.cb2) self.othergarbage = []
Example #30
Source File: fixtures.py From pytest with MIT License | 5 votes |
def test_request_garbage(self, testdir): try: import xdist # noqa except ImportError: pass else: pytest.xfail("this test is flaky when executed with xdist") testdir.makepyfile( """ import sys import pytest from _pytest.fixtures import PseudoFixtureDef import gc @pytest.fixture(autouse=True) def something(request): original = gc.get_debug() gc.set_debug(gc.DEBUG_SAVEALL) gc.collect() yield try: gc.collect() leaked = [x for _ in gc.garbage if isinstance(_, PseudoFixtureDef)] assert leaked == [] finally: gc.set_debug(original) def test_func(): pass """ ) result = testdir.runpytest_subprocess() result.stdout.fnmatch_lines(["* 1 passed in *"])