[docs] minor bug in python documentation 2.7 - multiprocessing

Sandro Tosi sandro.tosi at gmail.com
Tue May 17 00:16:29 CEST 2011


Hi Christian,
thanks for your email.

On Wed, Apr 27, 2011 at 10:28, Christian Herdtweck
<christian.herdtweck at tuebingen.mpg.de> wrote:
> In the description of Pipe the docu says:
> If duplex is False then the pipe is unidirectional: conn1 can only be used
> for receiving messages and conn2 can only be used for sending messages.
>
> which is exactly the other way round as used in the the example on the same
> page further down, where the first connection sends and the second receives:
>>>> from multiprocessing import Pipe
>>>> a, b = Pipe()
>>>> a.send([1, 'hello', None])
>>>> b.recv()
>
>  I do not know which one is correct

since True is the default value for duplex, in this case both
connections can send&receive:

./python
Python 2.7.1+ (2.7:a56cd7aeac5e+, Mar 29 2011, 00:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from multiprocessing import Pipe
>>> a, b = Pipe()
>>> a.send([1, 'hello', None])
>>> b.send([2, 'spam', True])
>>> a.recv()
[2, 'spam', True]
>>> b.recv()
[1, 'hello', None]
>>>

while passing explictly False to Pipe():

>>> a, b = Pipe(False)
>>> a.send([1, 'hello', None])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: connection is read-only
>>> b.send([2, 'spam', True])
>>> a.recv()
[2, 'spam', True]
>>> b.recv()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: connection is write-only
>>>

Regards,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi


More information about the docs mailing list