mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-41586: Add pipesize parameter to subprocess & F_GETPIPE_SZ and F_SETPIPE_SZ to fcntl. (GH-21921)
* Add F_SETPIPE_SZ and F_GETPIPE_SZ to fcntl module * Add pipesize parameter for subprocess.Popen class This will allow the user to control the size of the pipes. On linux the default is 64K. When a pipe is full it blocks for writing. When a pipe is empty it blocks for reading. On processes that are very fast this can lead to a lot of wasted CPU cycles. On a typical Linux system the max pipe size is 1024K which is much better. For high performance-oriented libraries such as xopen it is nice to be able to set the pipe size. The workaround without this feature is to use my_popen_process.stdout.fileno() in conjuction with fcntl and 1031 (value of F_SETPIPE_SZ) to acquire this behavior.
This commit is contained in:
parent
bf838227c3
commit
23c0fb8edd
8 changed files with 102 additions and 3 deletions
|
@ -565,6 +565,14 @@ all_ins(PyObject* m)
|
|||
if (PyModule_AddIntMacro(m, F_SHLCK)) return -1;
|
||||
#endif
|
||||
|
||||
/* Linux specifics */
|
||||
#ifdef F_SETPIPE_SZ
|
||||
if (PyModule_AddIntMacro(m, F_SETPIPE_SZ)) return -1;
|
||||
#endif
|
||||
#ifdef F_GETPIPE_SZ
|
||||
if (PyModule_AddIntMacro(m, F_GETPIPE_SZ)) return -1;
|
||||
#endif
|
||||
|
||||
/* OS X specifics */
|
||||
#ifdef F_FULLFSYNC
|
||||
if (PyModule_AddIntMacro(m, F_FULLFSYNC)) return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue