當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。