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
import asyncio
import logging
import socket
import sys
from .marshal import encoder
logger = logging.getLogger(__name__)
INET_FAMILIES = socket.AF_INET, socket.AF_INET6
class Protocol(asyncio.Protocol):
"""asyncio low-level ZEO base interface
"""
......@@ -41,7 +45,16 @@ class Protocol(asyncio.Protocol):
def connection_made(self, transport):
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
paused = self.paused
output = self.output
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