8000 gh-121313: Limit the reading size from pipes to their default buffer size on Unix systems by aplaikner · Pull Request #121315 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-121313: Limit the reading size from pipes to their default buffer size on Unix systems #121315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create constant for default number of pages per pipe
  • Loading branch information
aplaikner committed Jul 7, 2024
commit 94d4c4a5127326d7de52d2c142c563082b7c69ba
7 changes: 6 additions & 1 deletion Lib/multiprocessing/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ def _get_more_data(self, ov, maxsize):
f.write(ov.getbuffer())
return f

"""
The default size of a pipe on Linux systems is 16 times the base page size:
https://man7.org/linux/man-pages/man7/pipe.7.html
"""
PAGES_PER_PIPE = 16

class Connection(_ConnectionBase):
"""
Expand All @@ -380,7 +385,7 @@ def _close(self, _close=os.close):
_write = os.write
_read = os.read
_base_page_size = os.sysconf(os.sysconf_names['SC_PAGESIZE'])
_default_pipe_size = _base_page_size * 16
_default_pipe_size = _base_page_size * PAGES_PER_PIPE

def _send(self, buf, write=_write):
remaining = len(buf)
Expand Down
Loading
0