(original) (raw)
changeset: 74036:775319cebaa3 branch: 2.7 parent: 74033:038616802b65 user: Charles-François Natali neologix@free.fr date: Sun Dec 18 18:22:24 2011 +0100 files: Lib/threading.py Misc/NEWS description: Issue #11870: threading: Properly reinitialize threads internal locks and condition variables to avoid deadlocks in child processes. diff -r 038616802b65 -r 775319cebaa3 Lib/threading.py --- a/Lib/threading.py Sun Dec 18 15:52:48 2011 +0100 +++ b/Lib/threading.py Sun Dec 18 18:22:24 2011 +0100 @@ -878,22 +878,19 @@ current = current_thread() with _active_limbo_lock: for thread in _active.itervalues(): + # Any lock/condition variable may be currently locked or in an + # invalid state, so we reinitialize them. + if hasattr(thread, '_reset_internal_locks'): + 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._Thread__ident = ident - # Any condition variables hanging off of the active thread may - # be in an invalid state, so we reinitialize them. - if hasattr(thread, '_reset_internal_locks'): - 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._Thread__stopped = True + thread._Thread__stop() _limbo.clear() _active.clear() diff -r 038616802b65 -r 775319cebaa3 Misc/NEWS --- a/Misc/NEWS Sun Dec 18 15:52:48 2011 +0100 +++ b/Misc/NEWS Sun Dec 18 18:22:24 2011 +0100 @@ -86,6 +86,9 @@ 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. /neologix@free.fr