Workflow Time

It is important that workflow_time functions be used isntead of the regular time within the decider. The decider requires deterministic time and sleep related to the workflow execution.

botoflow.workflow_time.time() → integer

Return the current time in seconds since the Epoch. Fractions of a second will not be presented as in the time.time().

from botoflow import coroutine
from botoflow.workflow_time import time

...

@coroutine
def run_after(self, when):
    if time() > when:
        yield Activities.some_activity()
Raises
TypeError -- If the function is called not in DecisionContext
Returns
Returns the workflow's time in seconds since epoch.
Return type
int
botoflow.workflow_time.sleep(seconds)

Value that becomes ready after the specified delay. It acts like time.sleep() if used together with a yield.

from botoflow import coroutine
from botoflow.workflow_time import sleep

...

@coroutine
def sleeping(self, time_to_sleep):
    yield sleep(time_to_sleep)

@coroutine
def manual_timeout(self, time_to_sleep):
    # *for illustration purposes*, you should prefer using activity start_to_close timeout instead
    activity_future = Activities.long_activity()
    yield sleep(time_to_sleep)
    return activity_future.done()
Raises
Returns

Future representing the timer

Return type

botoflow.core.future.Future

botoflow.workflow_time.is_replaying()

Indicates if the workflow is currently replaying (True) or generating (False) new decisions.

This could be useful for filtering out logs for transitions that have already completed. See: BotoflowFilter.

Returns
True if the current state in the workflow being replayed.
Return type
bool
Raises
TypeError -- If the method is called not in the DecisionContext.