diff options
author | R. David Murray <rdmurray@bitdance.com> | 2009-07-29 15:40:30 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2009-07-29 15:40:30 (GMT) |
commit | a44c6b325f21647a48f787215f0959de887ae08b (patch) | |
tree | 992a5e3564537cb0161a83dd9ed0d777000936ac /Doc | |
parent | 0c40786c7351639e6d71573c4050143c478c4a58 (diff) | |
download | cpython-a44c6b325f21647a48f787215f0959de887ae08b.zip cpython-a44c6b325f21647a48f787215f0959de887ae08b.tar.gz cpython-a44c6b325f21647a48f787215f0959de887ae08b.tar.bz2 |
Merged revisions 74063 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
NB: the news item for r73708 seems to have inadvertently been included in a
different, unrelated merge set (r74055). I restored it here.
................
r74063 | alexandre.vassalotti | 2009-07-17 08:07:01 -0400 (Fri, 17 Jul 2009) | 17 lines
Merged revisions 73694,73708,73738 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73694 | jesse.noller | 2009-06-29 14:24:26 -0400 (Mon, 29 Jun 2009) | 1 line
Issue 5740: multiprocessing.connection.* authkey fixes
........
r73708 | jesse.noller | 2009-06-30 13:11:52 -0400 (Tue, 30 Jun 2009) | 1 line
Resolves issues 5155, 5313, 5331 - bad file descriptor error with processes in processes
........
r73738 | r.david.murray | 2009-06-30 22:49:10 -0400 (Tue, 30 Jun 2009) | 2 lines
Make punctuation prettier and break up run-on sentence.
........
................
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/multiprocessing.rst | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index d1b22db..d3cfa0a 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -1713,7 +1713,7 @@ authentication* using the :mod:`hmac` module. generally be omitted since it can usually be inferred from the format of *address*. (See :ref:`multiprocessing-address-formats`) - If *authentication* is ``True`` or *authkey* is a string then digest + If *authenticate* is ``True`` or *authkey* is a string then digest authentication is used. The key used for authentication will be either *authkey* or ``current_process().authkey)`` if *authkey* is ``None``. If authentication fails then :exc:`AuthenticationError` is raised. See @@ -1755,7 +1755,7 @@ authentication* using the :mod:`hmac` module. If *authkey* is ``None`` and *authenticate* is ``True`` then ``current_process().authkey`` is used as the authentication key. If - *authkey* is ``None`` and *authentication* is ``False`` then no + *authkey* is ``None`` and *authenticate* is ``False`` then no authentication is done. If authentication fails then :exc:`AuthenticationError` is raised. See :ref:`multiprocessing-auth-keys`. @@ -2097,6 +2097,38 @@ Explicitly pass resources to child processes for i in range(10): Process(target=f, args=(lock,)).start() +Beware replacing sys.stdin with a "file like object" + + :mod:`multiprocessing` originally unconditionally called:: + + os.close(sys.stdin.fileno()) + + in the :meth:`multiprocessing.Process._bootstrap` method --- this resulted + in issues with processes-in-processes. This has been changed to:: + + sys.stdin.close() + sys.stdin = open(os.devnull) + + Which solves the fundamental issue of processes colliding with each other + resulting in a bad file descriptor error, but introduces a potential danger + to applications which replace :func:`sys.stdin` with a "file-like object" + with output buffering. This danger is that if multiple processes call + :func:`close()` on this file-like object, it could result in the same + data being flushed to the object multiple times, resulting in corruption. + + If you write a file-like object and implement your own caching, you can + make it fork-safe by storing the pid whenever you append to the cache, + and discarding the cache when the pid changes. For example:: + + @property + def cache(self): + pid = os.getpid() + if pid != self._pid: + self._pid = pid + self._cache = [] + return self._cache + + For more information, see :issue:`5155`, :issue:`5313` and :issue:`5331` Windows ~~~~~~~ |