Skip to content

Commit

Permalink
Issue #19478: Make choice of semaphore prefix more flexible.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibturn committed Nov 2, 2013
1 parent 32dfef8 commit e943697
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Lib/multiprocessing/process.py
Expand Up @@ -301,10 +301,16 @@ def __init__(self):
self._parent_pid = None
self._popen = None
self._config = {'authkey': AuthenticationString(os.urandom(32)),
'semprefix': 'mp'}
'semprefix': '/mp'}
# Note that some versions of FreeBSD only allow named
# semaphores to have names of up to 14 characters. Therfore
# semaphores to have names of up to 14 characters. Therefore
# we choose a short prefix.
#
# On MacOSX in a sandbox it may be necessary to use a
# different prefix -- see #19478.
#
# Everything in self._config will be inherited by descendant
# processes.


_current_process = _MainProcess()
Expand Down
4 changes: 2 additions & 2 deletions Lib/multiprocessing/synchronize.py
Expand Up @@ -115,8 +115,8 @@ def __setstate__(self, state):

@staticmethod
def _make_name():
return '/%s-%s' % (process.current_process()._config['semprefix'],
next(SemLock._rand))
return '%s-%s' % (process.current_process()._config['semprefix'],
next(SemLock._rand))

#
# Semaphore
Expand Down

0 comments on commit e943697

Please sign in to comment.