summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/semaphore_tracker.py
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-08-22 10:38:57 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2013-08-22 10:38:57 (GMT)
commit7d2d43c0b15b8062c9b5d672a78e653abe2e1d91 (patch)
treeabc0049e1078fafc3c66f0463b8e9f70e2004d0e /Lib/multiprocessing/semaphore_tracker.py
parent0718f70131e4bc3756f453eb2f0c9ef8ed2fa843 (diff)
downloadcpython-7d2d43c0b15b8062c9b5d672a78e653abe2e1d91.zip
cpython-7d2d43c0b15b8062c9b5d672a78e653abe2e1d91.tar.gz
cpython-7d2d43c0b15b8062c9b5d672a78e653abe2e1d91.tar.bz2
Stop making fork server have copy of semaphore_tracker_fd.
Diffstat (limited to 'Lib/multiprocessing/semaphore_tracker.py')
-rw-r--r--Lib/multiprocessing/semaphore_tracker.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/multiprocessing/semaphore_tracker.py b/Lib/multiprocessing/semaphore_tracker.py
index 4a2d636..99a0dd4 100644
--- a/Lib/multiprocessing/semaphore_tracker.py
+++ b/Lib/multiprocessing/semaphore_tracker.py
@@ -26,6 +26,7 @@ from . import current_process
__all__ = ['ensure_running', 'register', 'unregister']
+_semaphore_tracker_fd = None
_lock = threading.Lock()
@@ -34,9 +35,9 @@ def ensure_running():
This can be run from any process. Usually a child process will use
the semaphore created by its parent.'''
+ global _semaphore_tracker_fd
with _lock:
- config = current_process()._config
- if config.get('semaphore_tracker_fd') is not None:
+ if _semaphore_tracker_fd is not None:
return
fds_to_pass = []
try:
@@ -44,7 +45,7 @@ def ensure_running():
except Exception:
pass
cmd = 'from multiprocessing.semaphore_tracker import main; main(%d)'
- r, semaphore_tracker_fd = util.pipe()
+ r, w = util.pipe()
try:
fds_to_pass.append(r)
# process will out live us, so no need to wait on pid
@@ -53,10 +54,10 @@ def ensure_running():
args += ['-c', cmd % r]
util.spawnv_passfds(exe, args, fds_to_pass)
except:
- os.close(semaphore_tracker_fd)
+ os.close(w)
raise
else:
- config['semaphore_tracker_fd'] = semaphore_tracker_fd
+ _semaphore_tracker_fd = w
finally:
os.close(r)
@@ -77,8 +78,7 @@ def _send(cmd, name):
# posix guarantees that writes to a pipe of less than PIPE_BUF
# bytes are atomic, and that PIPE_BUF >= 512
raise ValueError('name too long')
- fd = current_process()._config['semaphore_tracker_fd']
- nbytes = os.write(fd, msg)
+ nbytes = os.write(_semaphore_tracker_fd, msg)
assert nbytes == len(msg)