Commit 3d886d42 authored by Jim Fulton's avatar Jim Fulton

Try to make sure TCP_NODELAY is set on INET sockets.

This is a nasty work around for: https://bugs.python.org/issue27456

It can't always be applied.  For example, it can't be applied to Linux
SSL sockets using the asyncio-provided loop.
parent 48defe9f
from struct import unpack from struct import unpack
import asyncio import asyncio
import logging import logging
import socket
import sys
from .marshal import encoder from .marshal import encoder
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
INET_FAMILIES = socket.AF_INET, socket.AF_INET6
class Protocol(asyncio.Protocol): class Protocol(asyncio.Protocol):
"""asyncio low-level ZEO base interface """asyncio low-level ZEO base interface
""" """
...@@ -41,7 +45,16 @@ class Protocol(asyncio.Protocol): ...@@ -41,7 +45,16 @@ class Protocol(asyncio.Protocol):
def connection_made(self, transport): def connection_made(self, transport):
logger.info("Connected %s", self) logger.info("Connected %s", self)
if (sys.version_info < (3, 6) and
hasattr(transport, '_sock') and
transport._sock.family in INET_FAMILIES
):
# See https://bugs.python.org/issue27456 :(
transport._sock.setsockopt(
socket.IPPROTO_TCP, socket.TCP_NODELAY, True)
self.transport = transport self.transport = transport
paused = self.paused paused = self.paused
output = self.output output = self.output
append = output.append append = output.append
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment