diff --git a/taskflow/patterns/graph_flow.py b/taskflow/patterns/graph_flow.py index 46c7394a..7e051db0 100644 --- a/taskflow/patterns/graph_flow.py +++ b/taskflow/patterns/graph_flow.py @@ -61,6 +61,9 @@ class Flow(linear_flow.Flow): break return runner + def __len__(self): + return len(self._graph) + @decorators.locked def add_dependency(self, provider_uuid, requirer_uuid): """Connects provider to requirer where provider will now be required diff --git a/taskflow/patterns/linear_flow.py b/taskflow/patterns/linear_flow.py index c64635d8..96ef74e9 100644 --- a/taskflow/patterns/linear_flow.py +++ b/taskflow/patterns/linear_flow.py @@ -120,6 +120,9 @@ class Flow(base.Flow): except (IndexError, ValueError): pass + def __len__(self): + return len(self._runners) + def _connect(self): if self._connected: return self._runners