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
#!/usr/bin/env python3
"""
GIL Release Diagnostic Test
Tests whether the GIL is actually being released during Phase 2 parsing.
Uses threading.Event to confirm other threads can run while Phase 2 is executing.
"""
"""Load a test fixture."""
= . / / / /
return
"""
Diagnostic test: If GIL is released, other threads should run.
If GIL is NOT released, the second thread will block waiting for the event,
then timeout and report failure.
"""
=
=
=
"""Second thread waits for signal that parsing is happening."""
# Wait for reader to start
# Now GIL should be released during parsing
# If it is, we can acquire it and this will complete quickly
return True
return False
# Start thread 2
=
# In main thread, start reading
# Let thread 2 start waiting
# Read one record to trigger Phase 2 parsing
=
# Do some work
= 0
+= 1
# Just read 100 records for test
break