Index: Lib/threading.py =================================================================== --- Lib/threading.py (révision 66223) +++ Lib/threading.py (copie de travail) @@ -835,16 +835,19 @@ new_active = {} current = current_thread() with _active_limbo_lock: - for ident, thread in _active.items(): + for thread in _active.values(): if thread is current: - # There is only one active thread. + # 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 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._stopped = True _limbo.clear() _active.clear() Index: Lib/test/test_threading.py =================================================================== --- Lib/test/test_threading.py (révision 66223) +++ Lib/test/test_threading.py (copie de travail) @@ -346,7 +346,7 @@ # a thread, which waits for the main program to terminate def joiningfunc(mainthread): mainthread.join() - print('end of thread') + os.write(1, b'end of thread\\n') \n""" + script import subprocess @@ -365,7 +365,7 @@ args=(threading.current_thread(),)) t.start() time.sleep(0.1) - print('end of main') + os.write(1, b'end of main\\n') """ self._run_and_join(script) @@ -384,12 +384,11 @@ t = threading.Thread(target=joiningfunc, args=(threading.current_thread(),)) t.start() - print('end of main') + os.write(1, b'end of main\\n') """ self._run_and_join(script) - # XXX This test hangs! - def Xtest_3_join_in_forked_from_thread(self): + def test_3_join_in_forked_from_thread(self): # Like the test above, but fork() was called from a worker thread # In the forked process, the main Thread object must be marked as stopped. import os @@ -405,7 +404,7 @@ t = threading.Thread(target=joiningfunc, args=(main_thread,)) - print('end of main') + os.write(1, b'end of main\\n') t.start() t.join() # Should not block: main_thread is already stopped