本文整理汇总了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
示例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()))