diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2018-12-03 19:08:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 19:08:13 (GMT) |
commit | 3bc0ebab17bf5a2c29d2214743c82034f82e6573 (patch) | |
tree | 4dd0d06eb85963408b9d811b19d07116a51a70c7 /Lib/asyncio/base_events.py | |
parent | 3bb150d8148e3cc08418077a58f43e064b9fde61 (diff) | |
download | cpython-3bc0ebab17bf5a2c29d2214743c82034f82e6573.zip cpython-3bc0ebab17bf5a2c29d2214743c82034f82e6573.tar.gz cpython-3bc0ebab17bf5a2c29d2214743c82034f82e6573.tar.bz2 |
bpo-35380: Enable TCP_NODELAY for proactor event loop (#10867)
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r-- | Lib/asyncio/base_events.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index f5ab6e7..60a189b 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -168,6 +168,17 @@ def _run_until_complete_cb(fut): futures._get_loop(fut).stop() +if hasattr(socket, 'TCP_NODELAY'): + def _set_nodelay(sock): + if (sock.family in {socket.AF_INET, socket.AF_INET6} and + sock.type == socket.SOCK_STREAM and + sock.proto == socket.IPPROTO_TCP): + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) +else: + def _set_nodelay(sock): + pass + + class _SendfileFallbackProtocol(protocols.Protocol): def __init__(self, transp): if not isinstance(transp, transports._FlowControlMixin): |