From cf53ae2171d01eed0e1c902b51da27b5bdfbc143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Sun, 18 Dec 2011 16:05:07 +0100 Subject: Issue #8035: urllib: Fix a bug where the client could remain stuck after a redirection or an error. --- Lib/urllib/request.py | 2 -- Misc/NEWS | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index ca17da5..b41dd7e 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1732,7 +1732,6 @@ class URLopener: def http_error_default(self, url, fp, errcode, errmsg, headers): """Default error handler: close the connection and raise IOError.""" - void = fp.read() fp.close() raise HTTPError(url, errcode, errmsg, headers, None) @@ -1923,7 +1922,6 @@ class FancyURLopener(URLopener): newurl = headers['uri'] else: return - void = fp.read() fp.close() # In case the server sent a relative URL, join with original: diff --git a/Misc/NEWS b/Misc/NEWS index 94af446..72b33b9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -97,6 +97,9 @@ Core and Builtins Library ------- +- Issue #8035: urllib: Fix a bug where the client could remain stuck after a + redirection or an error. + - Issue #10350: Read and save errno before calling a function which might overwrite it. Original patch by Hallvard B Furuseth. -- cgit v0.12 From 6d5f9e73d973a9ec5a68dfc0bc1859e6e4f50896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Sun, 18 Dec 2011 18:35:09 +0100 Subject: Issue #11870: threading: Properly reinitialize threads internal locks and condition variables to avoid deadlocks in child processes. --- Lib/threading.py | 11 ++++------- Misc/NEWS | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/threading.py b/Lib/threading.py index 6653f6e..043e6c8 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1068,21 +1068,18 @@ def _after_fork(): current = current_thread() with _active_limbo_lock: for thread in _active.values(): + # Any lock/condition variable may be currently locked or in an + # invalid state, so we reinitialize them. + thread._reset_internal_locks() if thread is current: # There is only one active thread. We reset the ident to # its new value since it can have changed. ident = _get_ident() thread._ident = ident - # Any condition variables hanging off of the active thread may - # be in an invalid state, so we reinitialize them. - thread._reset_internal_locks() new_active[ident] = thread else: # All the others are already stopped. - # We don't call _Thread__stop() because it tries to acquire - # thread._Thread__block which could also have been held while - # we forked. - thread._stopped = True + thread._stop() _limbo.clear() _active.clear() diff --git a/Misc/NEWS b/Misc/NEWS index 72b33b9..4be3a6b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -97,6 +97,9 @@ Core and Builtins Library ------- +- Issue #11870: threading: Properly reinitialize threads internal locks and + condition variables to avoid deadlocks in child processes. + - Issue #8035: urllib: Fix a bug where the client could remain stuck after a redirection or an error. -- cgit v0.12 From b055bf6acbac7245ea943143be7313912a692902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Sun, 18 Dec 2011 18:45:16 +0100 Subject: Issue #11870: threading: Properly reinitialize threads internal locks and condition variables to avoid deadlocks in child processes. --- Lib/threading.py | 11 ++++------- Misc/NEWS | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/threading.py b/Lib/threading.py index 8d505b7..2362be6 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1047,21 +1047,18 @@ def _after_fork(): current = current_thread() with _active_limbo_lock: for thread in _active.values(): + # Any lock/condition variable may be currently locked or in an + # invalid state, so we reinitialize them. + thread._reset_internal_locks() if thread is current: # There is only one active thread. We reset the ident to # its new value since it can have changed. ident = get_ident() thread._ident = ident - # Any condition variables hanging off of the active thread may - # be in an invalid state, so we reinitialize them. - thread._reset_internal_locks() new_active[ident] = thread else: # All the others are already stopped. - # We don't call _Thread__stop() because it tries to acquire - # thread._Thread__block which could also have been held while - # we forked. - thread._stopped = True + thread._stop() _limbo.clear() _active.clear() diff --git a/Misc/NEWS b/Misc/NEWS index 85667cc..2114c4b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -419,6 +419,9 @@ Core and Builtins Library ------- +- Issue #11870: threading: Properly reinitialize threads internal locks and + condition variables to avoid deadlocks in child processes. + - Issue #8035: urllib: Fix a bug where the client could remain stuck after a redirection or an error. -- cgit v0.12