-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.py
93 lines (79 loc) · 1.91 KB
/
test.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
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
import unthrow
import inspect
import dis
import traceback
import sys
import gc
import testmod
fullTrace=[]
class context_blocker:
def __enter__(self):
print("Start with")
def __exit__(self,type,value,traceback):
print("End with")
def exceptionTest():
unthrow.stop("I'm stopping here")
def mainApp(x):
# import testmod
# unthrow.traceall=True
print("RUN IN TEST MODULE")
testmod.runtest()
print("RUN IN EXEC")
exec("for c in range(100):\n print(c)",{},{})
print("RUN LOCALLY")
for c in range(100):
print(c%10,end=' ')
print("RUN nothing")
d=0
# it=unthrow.test_iter(500)
it=range(500)
# while True:
# d=d+1
for c in it:
pass
# unthrow.traceall=False
# d=c
# print(c)
print("Done nothing",d)
print("Manual throwing")
for c in range(10):
print("L:",c)
if c==3 or c==5:
print("TRY THROW")
exceptionTest()
print("L2:",c)
print("RUN BLOCKED by with")
with context_blocker() as b:
for c in range(100):
print(".",end="")
print("RUN BLOCKED BY TRY, finally")
try:
for c in range(100):
print("*",end="")
print("Loop done")
except ValueError as v:
pass
finally:
for c in range(10):
print("F",end="")
print("RUN with another exception catch but no finally")
try:
for c in range(100):
print("*",end="")
print("Loop done")
except ValueError as v:
pass
print("END APP")
resume_info=None
x=["woo"]
r=unthrow.Resumer()
r.set_interrupt_frequency(2)
while r.finished==False:
print("@",end="")
r.run_once(mainApp,x)
print("Doing something outside everything")
for c in range(100):
print(".",end="")
resume_info=None
#print(dis.dis(mainApp))
print("RC X3 should be 2, otherwise ref leak:",sys.getrefcount(x))