summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-11-21 02:04:21 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2014-11-21 02:04:21 +0100
commit1c98a20a9d35dc378004bf7c54ca0cfae04eab6c (patch)
tree5da9f953d0ffa8d1d2ae31e7c718c528bd92335e /Python
parent14f28b80cd0f835f58fe0ef6f9529ce55633cb84 (diff)
downloadcpython-1c98a20a9d35dc378004bf7c54ca0cfae04eab6c.tar.gz
Issue #21963: backout issue #1856 patch (avoid crashes and lockups when
daemon threads run while the interpreter is shutting down; instead, these threads are now killed when they try to take the GIL), as it seems to break some existing code.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c12
-rw-r--r--Python/pythonrun.c9
-rw-r--r--Python/thread_pthread.h4
3 files changed, 3 insertions, 22 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index dad5e1cdc9..682a1e7e48 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -355,12 +355,6 @@ PyEval_RestoreThread(PyThreadState *tstate)
if (interpreter_lock) {
int err = errno;
PyThread_acquire_lock(interpreter_lock, 1);
- /* _Py_Finalizing is protected by the GIL */
- if (_Py_Finalizing && tstate != _Py_Finalizing) {
- PyThread_release_lock(interpreter_lock);
- PyThread_exit_thread();
- assert(0); /* unreachable */
- }
errno = err;
}
#endif
@@ -1025,12 +1019,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
PyThread_acquire_lock(interpreter_lock, 1);
- /* Check if we should make a quick exit. */
- if (_Py_Finalizing && _Py_Finalizing != tstate) {
- PyThread_release_lock(interpreter_lock);
- PyThread_exit_thread();
- }
-
if (PyThreadState_Swap(tstate) != NULL)
Py_FatalError("ceval: orphan tstate");
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 05bb62b64a..ade5efee0c 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -91,8 +91,6 @@ int _Py_QnewFlag = 0;
int Py_NoUserSiteDirectory = 0; /* for -s and site.py */
int Py_HashRandomizationFlag = 0; /* for -R and PYTHONHASHSEED */
-PyThreadState *_Py_Finalizing = NULL;
-
/* Hack to force loading of object files */
int (*_PyOS_mystrnicmp_hack)(const char *, const char *, Py_ssize_t) = \
@@ -165,7 +163,6 @@ Py_InitializeEx(int install_sigs)
if (initialized)
return;
initialized = 1;
- _Py_Finalizing = NULL;
if ((p = Py_GETENV("PYTHONDEBUG")) && *p != '\0')
Py_DebugFlag = add_flag(Py_DebugFlag, p);
@@ -425,16 +422,12 @@ Py_Finalize(void)
* the threads created via Threading.
*/
call_sys_exitfunc();
+ initialized = 0;
/* Get current thread state and interpreter pointer */
tstate = PyThreadState_GET();
interp = tstate->interp;
- /* Remaining threads (e.g. daemon threads) will automatically exit
- after taking the GIL (in PyEval_RestoreThread()). */
- _Py_Finalizing = tstate;
- initialized = 0;
-
/* Disable signal handling */
PyOS_FiniInterrupts();
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 0c1fdfea2a..c9ed796cd0 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -242,9 +242,9 @@ void
PyThread_exit_thread(void)
{
dprintf(("PyThread_exit_thread called\n"));
- if (!initialized)
+ if (!initialized) {
exit(0);
- pthread_exit(0);
+ }
}
#ifdef USE_SEMAPHORES