Created
November 26, 2015 13:07
-
-
Save jbbarth/24858bc0bfd09653e6be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
commented
Nov 26, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment