forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT19-Cancel.py
More file actions
45 lines (33 loc) · 1.01 KB
/
Copy pathT19-Cancel.py
File metadata and controls
45 lines (33 loc) · 1.01 KB
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
44
45
"""
@Author: Chunel
@Contact: chunel@foxmail.com
@File: T19-Cancel
@Time: 2025/3/28 22:57
@Desc:
"""
import time
from pycgraph import GPipeline, StdFutureCStatus
from MyGNode.MyNode1 import MyNode1
from MyGNode.MyNode2 import MyNode2
def tutorial_cancel():
pipeline = GPipeline()
a, b, c, d = MyNode1(), MyNode2(), MyNode1(), MyNode2()
pipeline.registerGElement(a, set(), "nodeA")
pipeline.registerGElement(b, {a}, "nodeB")
pipeline.registerGElement(c, {a}, "nodeC")
pipeline.registerGElement(d, {b, c}, "nodeD")
pipeline.init()
result: StdFutureCStatus = pipeline.asyncRun()
print("pipeline async run first time, BEGIN.")
result.wait()
print("pipeline async run first time, FINISH.")
print("======================")
result = pipeline.asyncRun()
time.sleep(1.5)
pipeline.cancel()
print("pipeline async run second time, CANCEL.")
print("======================")
result.wait()
pipeline.destroy()
if __name__ == '__main__':
tutorial_cancel()