diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-07-31 22:41:57 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-07-31 22:41:57 (GMT) |
commit | 0b87831de940a5682300d3857d47c5713be4c8a6 (patch) | |
tree | 6e3dd3f83162c4f49cc5d3a540810d4b18b46cd6 /Lib/multiprocessing | |
parent | cac9e719cc12642dcc5718c5e842592844405ff9 (diff) | |
download | cpython-0b87831de940a5682300d3857d47c5713be4c8a6.zip cpython-0b87831de940a5682300d3857d47c5713be4c8a6.tar.gz cpython-0b87831de940a5682300d3857d47c5713be4c8a6.tar.bz2 |
Simplify code in multiprocessing.Connection.send_bytes().
Followup to issue #20540; patch by Serhiy.
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/connection.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index 3bc716f..2bf4435 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -400,17 +400,14 @@ class Connection(_ConnectionBase): if n > 16384: # The payload is large so Nagle's algorithm won't be triggered # and we'd better avoid the cost of concatenation. - chunks = [header, buf] - elif n > 0: + self._send(header) + self._send(buf) + else: # Issue # 20540: concatenate before sending, to avoid delays due # to Nagle's algorithm on a TCP socket. - chunks = [header + buf] - else: - # This code path is necessary to avoid "broken pipe" errors - # when sending a 0-length buffer if the other end closed the pipe. - chunks = [header] - for chunk in chunks: - self._send(chunk) + # Also note we want to avoid sending a 0-length buffer separately, + # to avoid "broken pipe" errors if the other end closed the pipe. + self._send(header + buf) def _recv_bytes(self, maxsize=None): buf = self._recv(4) |