Skip to content

Instantly share code, notes, and snippets.

@jbbarth
Created November 26, 2015 13:07
Show Gist options
  • Select an option

  • Save jbbarth/24858bc0bfd09653e6be to your computer and use it in GitHub Desktop.

Select an option

Save jbbarth/24858bc0bfd09653e6be to your computer and use it in GitHub Desktop.
import time
from simpleflow import (
activity,
Workflow,
futures,
)
@activity.with_attributes(task_list='quickstart', version='example')
class Increment(object):
def __init__(self, x):
return x + 1
@activity.with_attributes(task_list='quickstart', version='example')
class Double(object):
def __init__(self, x):
return x * 2
@activity.with_attributes(task_list='quickstart', version='example')
class Delay(object):
def __init__(self, t, x):
time.sleep(t)
return x
class BasicWorkflow(Workflow):
name = 'basic'
version = 'example'
task_list = 'example'
def run(self, x, t=30):
y = self.submit(Increment, x)
yy = self.submit(Delay, t, y)
z = self.submit(Double, y)
print '({x} + 1) * 2 = {result}'.format(
x=x,
result=z.result)
futures.wait(yy, z)
return z.result
@ybastide

Copy link
Copy Markdown
        def __unicode__(self):
            # return contents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment