[issue12196] add pipe2() to the os module

Charles-François Natali report at bugs.python.org
Fri May 27 17:51:51 CEST 2011


Charles-François Natali <neologix at free.fr> added the comment:

> Do you want to call the function with two arguments or one tuple with 2 items? You may test both :-)

The former. Fixed.

> Hum, I'm not sure that it's revelant to test the time

I didn't like it either, I just reused what's done in test_socket. Fixed.

> BaseTestCase.test_communicate_pipe_buf() on subprocess uses

Yeah, except that it doesn't work, POSIX's PIPE_BUF is the guaranteed limit for the write to be atomic, not the buffer size (furthermore the libc doesn't have any way to know the pipe's buffer size or max atomic write, it's just a defined constant).

$ cat /tmp/test_pipe.py 
import os

r, w = os.pipe()
max = os.fpathconf(w, 'PC_PIPE_BUF')
print(max)
os.write(w, 2 * max * b'x')
print('ok')

$ ./python /tmp/test_pipe.py 
4096
ok

> This constant should be moved to test.support.

Patch attached.
It uses a constant of 1MB, even on Windows. I hope it won't break there, you never know with Windows...

----------
Added file: http://bugs.python.org/file22151/support_pipe_max.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12196>
_______________________________________


More information about the Python-bugs-list mailing list