This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Shutdown exception in daemon thread
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: mhobbs, pitrou
Priority: normal Keywords:

Created on 2012-04-19 20:49 by mhobbs, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg158746 - (view) Author: Mike Hobbs (mhobbs) Date: 2012-04-19 20:49
This issue is very similar to the issue original reported in issue1722344, except that it occurs in daemon threads. Here's a sample exception:

Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/local/lib/python2.7/threading.py", line 505, in run
  File "/opt/8b/libr8/eb/util/graphite.py", line 86, in run
  File "/usr/local/lib/python2.7/Queue.py", line 168, in get
  File "/usr/local/lib/python2.7/threading.py", line 237, in wait
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

Investigating line 237 in threading.py shows that RuntimeError must have been set to None. The issue appears to be that Py_Finalize wipes all globals while there are still daemon threads running. Would it be correct to terminate daemon threads prior to wiping the globals, since the threads won't be able to accomplish much anyway?
msg158755 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-04-19 21:15
> Would it be correct to terminate daemon threads prior to wiping the
> globals, since the threads won't be able to accomplish much anyway?

Daemon threads are not actually "terminated" by the Python interpreter, they just keep running in the background until the process exits.
The situation should be much better in Python 3.2, where daemon threads are frozen (their execution is halted) when the interpreter starts to shutdown.

I don't think this will be ever fixed in 2.7, though. It's a slightly delicate change.
History
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58828
2012-04-19 21:15:23pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg158755

resolution: wont fix
stage: resolved
2012-04-19 20:49:28mhobbscreate