Provide the length of the flows.

Its useful to be able to check if a flow contains
anything by just inspecting the len() of the flow.
This can be used to avoid running a flow in the
first place if nothing is in said flow.

Change-Id: Ibfea7f10fc67d5dd3ddfa6f6fe6c08805562998a
This commit is contained in:
Joshua Harlow
2013-07-10 00:00:04 -07:00
parent 37edf7d4ff
commit 81d0884d55
2 changed files with 6 additions and 0 deletions

View File

@@ -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

View File

@@ -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