本文整理汇总了Python中gc.set_debug方法的典型用法代码示例。如果您正苦于以下问题:Python gc.set_debug方法的具体用法?Python gc.set_debug怎么用?Python gc.set_debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gc
的用法示例。
在下文中一共展示了gc.set_debug方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_saveall
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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)
示例2: test_main
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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()
示例3: init
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
def init(self):
import gc
# gc.DEBUG_OBJECTS not present in python3
gc.set_debug(gc.DEBUG_UNCOLLECTABLE|gc.DEBUG_SAVEALL)
self.prompt = ">"
self.previous = ""
self.set_tooltip(_("Enter Python expressions"))
self.gc = gc
self.env = {"dbstate": self.gui.dbstate,
"uistate": self.gui.uistate,
"db": self.gui.dbstate.db,
"gc": self.gc,
"self": self,
"Date": gramps.gen.lib.Date,
}
# GUI setup:
self.gui.textview.set_editable(True)
self.set_text("Python %s\n%s " % (sys.version, self.prompt))
self.gui.textview.connect('key-press-event', self.on_key_press)
示例4: tearDown
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
def tearDown(self):
# Restore gc state
del self.visit
gc.callbacks.remove(self.cb1)
gc.callbacks.remove(self.cb2)
gc.set_debug(self.debug)
if self.enabled:
gc.enable()
# destroy any uncollectables
gc.collect()
for obj in gc.garbage:
if isinstance(obj, Uncollectable):
obj.partner = None
del gc.garbage[:]
del self.othergarbage
gc.collect()
示例5: test_main
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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()
示例6: run
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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)
示例7: test_saveall
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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)
示例8: test
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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()
示例9: assert_cycles
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
def assert_cycles(expected=0):
def decorate(fn):
def go():
fn() # warmup, configure mappers, caches, etc.
gc_collect()
gc_collect()
gc_collect() # multiple calls seem to matter
# gc.set_debug(gc.DEBUG_COLLECTABLE)
try:
return fn() # run for real
finally:
unreachable = gc_collect()
assert unreachable <= expected
gc_collect()
return go
return decorate
示例10: test_saveall
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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)
示例11: test_main
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
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()
示例12: CollectGarbage
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
def CollectGarbage():
import gc
#gc.set_debug(gc.DEBUG_SAVEALL)
#gc.set_debug(gc.DEBUG_UNCOLLECTABLE)
from pprint import pprint
print "threshold:", gc.get_threshold()
print "unreachable object count:", gc.collect()
garbageList = gc.garbage[:]
for i, obj in enumerate(garbageList):
print "Object Num %d:" % i
pprint(obj)
#print "Referrers:"
#print(gc.get_referrers(o))
#print "Referents:"
#print(gc.get_referents(o))
print "Done."
#print "unreachable object count:", gc.collect()
#from pprint import pprint
#pprint(gc.garbage)
示例13: debug_cycles
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
def debug_cycles(self):
"""Debugging support"""
gc.set_debug(gc.DEBUG_SAVEALL)
gc.collect()
for obj in gc.garbage:
logging.debug(repr(obj) + " " + str(type(obj)))
示例14: __init__
# 需要导入模块: import gc [as 别名]
# 或者: from gc import set_debug [as 别名]
def __init__(self, interval=1.0, debug=False):
self.debug = debug
if debug:
gc.set_debug(gc.DEBUG_LEAK)
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.check)
self.threshold = gc.get_threshold()
gc.disable()
self.timer.start(interval * 1000)