當前位置: 首頁>>代碼示例>>Python>>正文


Python objgraph.count方法代碼示例

本文整理匯總了Python中objgraph.count方法的典型用法代碼示例。如果您正苦於以下問題:Python objgraph.count方法的具體用法?Python objgraph.count怎麽用?Python objgraph.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在objgraph的用法示例。


在下文中一共展示了objgraph.count方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_leak

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import count [as 別名]
def test_leak(self, container_factory, service_cls, config):
        # regression test for
        # https://github.com/mattbennett/nameko-sentry/issues/12

        container = container_factory(service_cls, config)
        container.start()

        gc.collect()
        count_before = objgraph.count('raven.breadcrumbs.BreadcrumbBuffer')

        with entrypoint_hook(container, 'broken') as hook:
            for _ in range(5):
                with pytest.raises(CustomException):
                    hook()

        gc.collect()
        count_after = objgraph.count('raven.breadcrumbs.BreadcrumbBuffer')
        assert count_before == count_after 
開發者ID:nameko,項目名稱:nameko-sentry,代碼行數:20,代碼來源:test_nameko_sentry.py

示例2: main

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import count [as 別名]
def main():
    x = WithDel()
    y = []
    z = []

    x.append(y)
    y.append(z)
    z.append(x)

    del x, y, z

    print("unreachable prior collection: %s" % gc.collect())
    print("unreachable after collection: %s" % len(gc.garbage))
    print("WithDel objects count:        %s" % objgraph.count('WithDel')) 
開發者ID:PacktPublishing,項目名稱:Expert-Python-Programming_Second-Edition,代碼行數:16,代碼來源:cyclic_references.py

示例3: run_objgraph

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import count [as 別名]
def run_objgraph(types):
    import objgraph
    import os
    import random
    objgraph.show_most_common_types(limit=50, shortnames=False)
    for type_ in types:
        count = objgraph.count(type_)
        print('%s objects: %d' % (type_, count))
        if count:
            objgraph.show_backrefs(
                random.choice(objgraph.by_type(type_)), max_depth=20,
                filename='/tmp/backrefs_%s_%d.dot' % (type_, os.getpid())) 
開發者ID:open-io,項目名稱:oio-swift,代碼行數:14,代碼來源:runserver.py


注:本文中的objgraph.count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。