diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2008-09-06 23:00:03 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2008-09-06 23:00:03 (GMT) |
commit | 5fe291f8175fde8cd5c55dd0d11486ddf82ef6b8 (patch) | |
tree | 58481fdd59d47e6b329d79599ea304985f359c2c /Lib/threading.py | |
parent | 0a608fdaac5b4422b9ade6ec7b44182902f2f9ce (diff) | |
download | cpython-5fe291f8175fde8cd5c55dd0d11486ddf82ef6b8.zip cpython-5fe291f8175fde8cd5c55dd0d11486ddf82ef6b8.tar.gz cpython-5fe291f8175fde8cd5c55dd0d11486ddf82ef6b8.tar.bz2 |
Issue #874900: fix behaviour of threading module after a fork.
Reviewed by Gregory P. Smith.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r-- | Lib/threading.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index 1d59cb0..b541d77 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -835,16 +835,19 @@ def _after_fork(): 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() |