-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop_flow.py
43 lines (31 loc) · 882 Bytes
/
stop_flow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import traceback
from simflow.control import Flow, Tee, Stop, run_flow
from simflow.sink import Console
from simflow.source import ForLoop
from simflow.transformer import SetStorageValue
def main():
"""
Just runs some example code.
"""
# setup the flow
flow = Flow(name="stopping the flow")
outer = ForLoop()
outer.config["max"] = 10
flow.actors.append(outer)
ssv = SetStorageValue()
ssv.config["storage_name"] = "current"
flow.actors.append(ssv)
tee = Tee()
tee.config["condition"] = "@{current} == 7"
flow.actors.append(tee)
stop = Stop()
tee.actors.append(stop)
console = Console()
flow.actors.append(console)
# run the flow
run_flow(flow, print_tree=True, cleanup=True)
if __name__ == "__main__":
try:
main()
except Exception as e:
print(traceback.format_exc())