This commit is contained in:
Antoine Pitrou 2011-12-18 19:00:16 +01:00
commit 0f694d72a2
3 changed files with 10 additions and 9 deletions

View File

@ -1047,21 +1047,18 @@ def _after_fork():
current = current_thread() current = current_thread()
with _active_limbo_lock: with _active_limbo_lock:
for thread in _active.values(): 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: if thread is current:
# There is only one active thread. We reset the ident to # There is only one active thread. We reset the ident to
# its new value since it can have changed. # its new value since it can have changed.
ident = get_ident() ident = get_ident()
thread._ident = 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 new_active[ident] = thread
else: else:
# All the others are already stopped. # All the others are already stopped.
# We don't call _Thread__stop() because it tries to acquire thread._stop()
# thread._Thread__block which could also have been held while
# we forked.
thread._stopped = True
_limbo.clear() _limbo.clear()
_active.clear() _active.clear()

View File

@ -1762,7 +1762,6 @@ class URLopener:
def http_error_default(self, url, fp, errcode, errmsg, headers): def http_error_default(self, url, fp, errcode, errmsg, headers):
"""Default error handler: close the connection and raise IOError.""" """Default error handler: close the connection and raise IOError."""
void = fp.read()
fp.close() fp.close()
raise HTTPError(url, errcode, errmsg, headers, None) raise HTTPError(url, errcode, errmsg, headers, None)
@ -1951,7 +1950,6 @@ class FancyURLopener(URLopener):
newurl = headers['uri'] newurl = headers['uri']
else: else:
return return
void = fp.read()
fp.close() fp.close()
# In case the server sent a relative URL, join with original: # In case the server sent a relative URL, join with original:

View File

@ -419,6 +419,12 @@ Core and Builtins
Library 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.
- Issue #13560: os.strerror() now uses the current locale encoding instead of - Issue #13560: os.strerror() now uses the current locale encoding instead of
UTF-8. UTF-8.