MCPcopy
hub / github.com/celery/celery / objgraph

Function objgraph

celery/worker/control.py:491–512  ·  view source on GitHub ↗

Create graph of uncollected objects (memory-leak debugging). Arguments: num (int): Max number of objects to graph. max_depth (int): Traverse at most n levels deep. type (str): Name of object to graph. Default is ``"Request"``.

(state, num=200, max_depth=10, type='Request')

Source from the content-addressed store, hash-verified

489 signature='[object_type=Request] [num=200 [max_depth=10]]',
490)
491def objgraph(state, num=200, max_depth=10, type='Request'): # pragma: no cover
492 """Create graph of uncollected objects (memory-leak debugging).
493
494 Arguments:
495 num (int): Max number of objects to graph.
496 max_depth (int): Traverse at most n levels deep.
497 type (str): Name of object to graph. Default is ``"Request"``.
498 """
499 try:
500 import objgraph as _objgraph
501 except ImportError:
502 raise ImportError('Requires the objgraph library')
503 logger.info('Dumping graph for type %r', type)
504 with tempfile.NamedTemporaryFile(prefix='cobjg',
505 suffix='.png', delete=False) as fh:
506 objects = _objgraph.by_type(type)[:num]
507 _objgraph.show_backrefs(
508 objects,
509 max_depth=max_depth, highlight=lambda v: v in objects,
510 filename=fh.name,
511 )
512 return {'filename': fh.name}
513
514
515@inspect_command()

Callers

nothing calls this directly

Calls 1

infoMethod · 0.45

Tested by

no test coverage detected