Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix periodic timer error on interpreter shutdown #423

Merged
merged 1 commit into from
Sep 24, 2019

Conversation

jd
Copy link
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
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