当前位置: 首页>>代码示例>>Python>>正文


Python gc.DEBUG_SAVEALL属性代码示例

本文整理汇总了Python中gc.DEBUG_SAVEALL属性的典型用法代码示例。如果您正苦于以下问题:Python gc.DEBUG_SAVEALL属性的具体用法?Python gc.DEBUG_SAVEALL怎么用?Python gc.DEBUG_SAVEALL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gc的用法示例。


在下文中一共展示了gc.DEBUG_SAVEALL属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_saveall

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_gc.py

示例2: init

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [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) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:21,代码来源:QueryGramplet.py

示例3: test_saveall

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [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) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:24,代码来源:test_gc.py

示例4: test_saveall

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [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) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:24,代码来源:test_gc.py

示例5: test_debug_stats

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [as 别名]
def test_debug_stats(self):
        self.assertEqual(1,gc.DEBUG_STATS)
        self.assertEqual(2,gc.DEBUG_COLLECTABLE)
        self.assertEqual(4,gc.DEBUG_UNCOLLECTABLE)
        self.assertEqual(8,gc.DEBUG_INSTANCES)
        self.assertEqual(16,gc.DEBUG_OBJECTS)
        self.assertEqual(32,gc.DEBUG_SAVEALL)
        self.assertEqual(62,gc.DEBUG_LEAK) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_gc.py

示例6: test_get_debug

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [as 别名]
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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_gc.py

示例7: test_debug_stats

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [as 别名]
def test_debug_stats(self):
        self.assertEqual(1,gc.DEBUG_STATS)
        self.assertEqual(2,gc.DEBUG_COLLECTABLE)
        self.assertEqual(4,gc.DEBUG_UNCOLLECTABLE)
        self.assertEqual(32,gc.DEBUG_SAVEALL)
        self.assertEqual(38,gc.DEBUG_LEAK) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:8,代码来源:test_gc.py

示例8: test_get_debug

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [as 别名]
def test_get_debug(self):
        state = [0,gc.DEBUG_STATS,gc.DEBUG_COLLECTABLE,gc.DEBUG_UNCOLLECTABLE,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)) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:7,代码来源:test_gc.py

示例9: test_garbage_at_shutdown

# 需要导入模块: import gc [as 别名]
# 或者: from gc import DEBUG_SAVEALL [as 别名]
def test_garbage_at_shutdown(self):
        import subprocess
        code = """if 1:
            import gc
            import _testcapi
            @_testcapi.with_tp_del
            class X:
                def __init__(self, name):
                    self.name = name
                def __repr__(self):
                    return "<X %%r>" %% self.name
                def __tp_del__(self):
                    pass

            x = X('first')
            x.x = x
            x.y = X('second')
            del x
            gc.set_debug(%s)
        """
        def run_command(code):
            p = subprocess.Popen([sys.executable, "-Wd", "-c", code],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE)
            stdout, stderr = p.communicate()
            p.stdout.close()
            p.stderr.close()
            self.assertEqual(p.returncode, 0)
            self.assertEqual(stdout.strip(), b"")
            return strip_python_stderr(stderr)

        stderr = run_command(code % "0")
        self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
                      b"shutdown; use", stderr)
        self.assertNotIn(b"<X 'first'>", stderr)
        # With DEBUG_UNCOLLECTABLE, the garbage list gets printed
        stderr = run_command(code % "gc.DEBUG_UNCOLLECTABLE")
        self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
                      b"shutdown", stderr)
        self.assertTrue(
            (b"[<X 'first'>, <X 'second'>]" in stderr) or
            (b"[<X 'second'>, <X 'first'>]" in stderr), stderr)
        # With DEBUG_SAVEALL, no additional message should get printed
        # (because gc.garbage also contains normally reclaimable cyclic
        # references, and its elements get printed at runtime anyway).
        stderr = run_command(code % "gc.DEBUG_SAVEALL")
        self.assertNotIn(b"uncollectable objects at shutdown", stderr) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:49,代码来源:test_gc.py


注:本文中的gc.DEBUG_SAVEALL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。