celery.utils.graph
Dependency graph implementation.
- exceptioncelery.utils.graph.CycleError
-
A cycle was detected in an acyclic graph.
- classcelery.utils.graph.DOT
-
Constants related to the dot format.
- ATTR='{name}={value}'
- ATTRSEP=', '
- DIRS={'digraph': '->', 'graph': '--'}
- EDGE='{INp}"{0}" {dir} "{1}" [{attrs}]'
- HEAD='\n{IN}{type} {id} {{\n{INp}graph [{attrs}]\n'
- NODE='{INp}"{0}" [{attrs}]'
- TAIL='{IN}}}'
- classcelery.utils.graph.DependencyGraph(it=None, formatter=None)
-
A directed acyclic graph of objects and their dependencies.
Supports a robust topological sort to detect the order in which they must be handled.
Takes an optional iterator of
(obj, dependencies)tuples to build the graph from.Warning
Does not support cycle detection.
- add_arc(obj)
-
Add an object to the graph.
- add_edge(A, B)
-
Add an edge from object
Ato objectB.I.e.
Adepends onB.
- connect(graph)
-
Add nodes from another graph.
- edges()
-
Return generator that yields for all edges in the graph.
- format(obj)
- items()
- iteritems()
- repr_node(obj, level=1, fmt='{0}({1})')
- to_dot(fh, formatter=None)
-
Convert the graph to DOT format.
- Parameters:
-
fh (IO) – A file, or a file-like object to write the graph to.
formatter (celery.utils.graph.GraphFormatter) – Custom graph formatter to use.
- topsort()
-
Sort the graph topologically.
- Returns:
-
of objects in the order in which they must be handled.
- Return type:
-
List
- update(it)
-
Update graph with data from a list of
(obj, deps)tuples.
- valency_of(obj)
-
Return the valency (degree) of a vertex in the graph.
- classcelery.utils.graph.GraphFormatter(root=None, type=None, id=None, indent=0, inw=' ', **scheme)
-
Format dependency graphs.
- FMT(fmt, *args, **kwargs)
- attr(name, value)
- attrs(d, scheme=None)
- draw_edge(a, b, scheme=None, attrs=None)
- draw_node(obj, scheme=None, attrs=None)
- edge(a, b, **attrs)
- edge_scheme={'arrowcolor': 'black', 'arrowsize': 0.7, 'color': 'darkseagreen4'}
- graph_scheme={'bgcolor': 'mintcream'}
- head(**attrs)
- label(obj)
- node(obj, **attrs)
- node_scheme={'color': 'palegreen4', 'fillcolor': 'palegreen3'}
- scheme={'arrowhead': 'vee', 'fontname': 'HelveticaNeue', 'shape': 'box', 'style': 'filled'}
- tail()
- term_scheme={'color': 'palegreen2', 'fillcolor': 'palegreen1'}
- terminal_node(obj, **attrs)
Copyright © 2017-2026 Asif Saif Uddin, core team & contributors. All rights reserved.
Celery is licensed under The BSD License (3 Clause, also known as the new BSD license). The license is an OSI approved Open Source license and is GPL-compatible.
https://docs.celeryq.dev/en/stable/internals/reference/celery.utils.graph.html