Skip to content

Fix periodic timer error on interpreter shutdown#423

Merged
zippolyte merged 1 commit intoDataDog:masterfrom
jd:fix-thread-on-shutdown
Sep 24, 2019
Merged

Fix periodic timer error on interpreter shutdown#423
zippolyte merged 1 commit intoDataDog:masterfrom
jd:fix-thread-on-shutdown

Conversation

@jd
Copy link
Copy Markdown
Contributor

@jd jd commented Aug 13, 2019

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.

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.
@jd jd requested a review from a team as a code owner August 13, 2019 09:54
Copy link
Copy Markdown
Contributor

@zippolyte zippolyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zippolyte zippolyte merged commit eee5523 into DataDog:master Sep 24, 2019
dabcoder pushed a commit to dabcoder/datadogpy that referenced this pull request Oct 25, 2019
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.
dabcoder pushed a commit to dabcoder/datadogpy that referenced this pull request Nov 28, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants