Skip to content

Commit

Permalink
allow running chain with pre-existing state dict
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Mar 22, 2020
1 parent 865884f commit 5a3e4c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions state_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,18 @@ def __init__(self, *functions, **kw):
self.debug = _DebugMethod(self)


def run(self, _raise_immediately=None, _return_after=None, **state):
def run(self, state=None, _raise_immediately=None, _return_after=None, **kw):
"""Run through the functions in the :py:attr:`functions` list.
:param dict state: the initial state dictionary for this run of the chain
:param bool _raise_immediately: if not ``None``, will override any
default for ``raise_immediately`` that was set in the constructor
:param str _return_after: if not ``None``, return after calling the function
with this name
:param dict state: remaining keyword arguments are used for the initial
state dictionary for this run of the state chain
:param kw: remaining keyword arguments are added to the ``state`` dict
:raises: :py:exc:`FunctionNotFound`, if there is no function named
``_return_after``
Expand Down Expand Up @@ -270,6 +271,11 @@ def run(self, _raise_immediately=None, _return_after=None, **state):
"""

if state is None:
state = {}
if kw:
state.update(kw)

if _raise_immediately is None:
_raise_immediately = self.default_raise_immediately

Expand Down

0 comments on commit 5a3e4c8

Please sign in to comment.