-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest_tracer.py
More file actions
107 lines (85 loc) · 1.84 KB
/
Copy pathtest_tracer.py
File metadata and controls
107 lines (85 loc) · 1.84 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
"""
Test the new python-csp tracer.
Includes regular and server processes and ALTing.
"""
__author__ = 'Sarah Mount <s.mount@wlv.ac.uk>'
__date__ = 'May 2010'
from csp.cspprocess import *
from csp.guards import Skip
ch = Channel()
@process
def client(inchan):
"""
readset = inchan
writeset =
"""
print(inchan.read())
return
@process
def foo(outchan, msg):
"""
readset =
writeset = outchan
"""
outchan.write(msg)
return
@process
def alt3(inchan1, inchan2, inchan3):
"""
readset = inchan1, inchan2, inchan3
writeset =
"""
alt = Alt(inchan1, inchan2, inchan3, Skip())
selects = 0
while selects < 3:
val = alt.select()
if val != 'Skip':
selects += 1
print(val)
return
@process
def simple():
print('SIMPLES')
return
@forever
def server():
while True:
print('server process')
yield
return
@forever
def server_write(outchan):
"""
readset =
writeset = outchan
"""
while True:
outchan.write('Hello server')
yield
return
@forever
def server_read(inchan):
"""
readset = inchan
writeset =
"""
while True:
print(inchan.read())
yield
return
if __name__ == '__main__':
from csp.tracer.tracer import csptrace
with csptrace():
chan, skip = Channel(), Skip()
skip //= foo(chan, 'hello world!'), client(chan)
Par(foo(chan, 1243), client(chan)).start()
chan1, chan2, chan3 = Channel(), Channel(), Channel()
Par(foo(chan1, 1),
foo(chan2, 2),
foo(chan3, 3),
alt3(chan1, chan2, chan3)).start()
simple().start()
server().start()
chan_s, skip = Channel(), Skip()
skip //= server_read(chan_s), server_write(chan_s)