Commit 54044db
Fix periodic timer error on interpreter shutdown (DataDog#423)
The current hack does not work, as I'm still able to see such messages in the
log:
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "pyenv/versions/2.7.12/lib/python2.7/threading.py", line 801, in __bootstrap_inner
File "python/lib/python2.7/site-packages/datadog/threadstats/periodic_timer.py", line 43, in run
File "pyenv/versions/2.7.12/lib/python2.7/threading.py", line 614, in wait
File "pyenv/versions/2.7.12/lib/python2.7/threading.py", line 355, in wait
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
This changes the current code to leverage the same hack that the `threading`
library uses: if the `sys` module is None, there's a good chance that's because
the interpreter is shutdown down.
This change also improves the waiting loop by using the return value from
`Event.wait()` which returns the value of the flag. That makes the thread
faster to quit when `end()` is called.1 parent a8d3bff commit 54044db
1 file changed
+10
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 22 | | |
36 | | - | |
37 | | - | |
| 23 | + | |
38 | 24 | | |
39 | 25 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments