cpython: 4ceca79d1c63 (original) (raw)

Mercurial > cpython

changeset 93526:4ceca79d1c63 2.7

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. [#21963]

Antoine Pitrou solipsis@pitrou.net
date Fri, 21 Nov 2014 02:04:21 +0100
parents 8bc29f5ebeff
children c9b4dc1ab7ae
files Include/pythonrun.h Lib/test/test_threading.py Misc/NEWS Python/ceval.c Python/pythonrun.c Python/thread_pthread.h
diffstat 6 files changed, 8 insertions(+), 71 deletions(-)[+] [-] Include/pythonrun.h 2 Lib/test/test_threading.py 43 Misc/NEWS 9 Python/ceval.c 12 Python/pythonrun.c 9 Python/thread_pthread.h 4

line wrap: on

line diff

--- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -147,8 +147,6 @@ PyAPI_FUNC(void) PyOS_FiniInterrupts(voi PyAPI_FUNC(void) PyByteArray_Fini(void); PyAPI_FUNC(void) _PyRandom_Fini(void); -PyAPI_DATA(PyThreadState ) _Py_Finalizing; - / Stuff with no proper home (yet) */ PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *); PyAPI_DATA(int) (*PyOS_InputHook)(void);

--- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -700,49 +700,6 @@ class ThreadJoinOnShutdown(BaseTestCase) output = "end of worker thread\nend of main thread\n" self.assertScriptHasOutput(script, output)

-

-

-

-

- @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ What's New in Python 2.7.9? Core and Builtins ----------------- +- Backout issue #1856 patch (avoid crashes and lockups when daemon threads

--- a/Python/ceval.c +++ b/Python/ceval.c @@ -355,12 +355,6 @@ PyEval_RestoreThread(PyThreadState *tsta if (interpreter_lock) { int err = errno; PyThread_acquire_lock(interpreter_lock, 1);

#endif @@ -1025,12 +1019,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int PyThread_acquire_lock(interpreter_lock, 1);

- if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate");

--- 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) = [](#l5.11) @@ -165,7 +163,6 @@ Py_InitializeEx(int install_sigs) if (initialized) return; initialized = 1;

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();

/* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); interp = tstate->interp;

- /* Disable signal handling */ PyOS_FiniInterrupts();

--- 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"));

} #ifdef USE_SEMAPHORES