-
Notifications
You must be signed in to change notification settings - Fork 0
/
greenlettest.py
53 lines (47 loc) · 948 Bytes
/
greenlettest.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
44
45
46
47
48
49
50
51
52
53
from greenlet import greenlet
import sys
def main():
# def test1():
# print 12
# gr2.switch()
# print 34
#
# def test2():
# print 56
# gr1.switch()
# print 78
#
# gr1 = greenlet(test1)
# gr2 = greenlet(test2)
#
## join(gr1)
## join(gr2)
#
# def test1(x, y):
# z = gr2.switch(x+y)
# print z
#
# def test2(u):
# print u
# gr1.switch(42)
#
# gr1 = greenlet(test1)
# gr2 = greenlet(test2)
# gr1.switch("hello", " world")
def test1():
try:
raise Exception("yo")
except:
print "test1 %r" % gr2.throw(*sys.exc_info())
def test2():
try:
gr1.switch()
print "ok"
except:
print sys.exc_info()
gr1 = greenlet(test1)
gr2 = greenlet(test2)
gr2.switch()
gr1.switch("hi")
if __name__ == '__main__':
main()