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


Python gc.get_debug方法代码示例

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


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

示例1: test_saveall

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

示例2: test_main

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

示例3: test_main

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

示例4: run

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

示例5: test_saveall

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

示例6: test

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

示例7: test_saveall

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

示例8: test_main

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

示例9: test_000_get_debug

# 需要导入模块: import gc [as 别名]
# 或者: from gc import get_debug [as 别名]
def test_000_get_debug(self):
        """get_debug should return 0 if set_debug has not been used"""
        self.assertEqual(gc.get_debug(), 0) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_gc.py

示例10: test_setdebug

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

示例11: test_get_debug

# 需要导入模块: import gc [as 别名]
# 或者: from gc import get_debug [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

示例12: test_request_garbage

# 需要导入模块: import gc [as 别名]
# 或者: from gc import get_debug [as 别名]
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 *"]) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:37,代码来源:fixtures.py

示例13: setUp

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

示例14: test_setdebug

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


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