Skip to content

Commit

Permalink
Merge pull request #37 from zopefoundation/TCP_NODELAY
Browse files Browse the repository at this point in the history
TCP_NODELAY
  • Loading branch information
jimfulton committed Jul 7, 2016
2 parents 1eb086d + a0fa2fe commit bff1a14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/ZEO/asyncio/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
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
"""
Expand Down Expand Up @@ -41,7 +45,15 @@ def close(self):

def connection_made(self, transport):
logger.info("Connected %s", self)


if sys.version_info < (3, 6):
sock = transport.get_extra_info('socket')
if sock is not None and sock.family in INET_FAMILIES:
# See https://bugs.python.org/issue27456 :(
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True)
self.transport = transport

paused = self.paused
output = self.output
append = output.append
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/asyncio/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Transport:

capacity = 1 << 64
paused = False
extra = dict(peername='1.2.3.4', sockname=('127.0.0.1', 4200))
extra = dict(peername='1.2.3.4', sockname=('127.0.0.1', 4200), socket=None)

def __init__(self, protocol):
self.data = []
Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/tests/InvalidationTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ def go(self, stop, commitdict, *threads):

def checkConcurrentUpdates2Storages_emulated(self):
self._storage = storage1 = self.openClientStorage()
storage2 = self.openClientStorage()
db1 = DB(storage1)
storage2 = self.openClientStorage()
db2 = DB(storage2)

cn = db1.open()
Expand All @@ -349,8 +349,8 @@ def checkConcurrentUpdates2Storages_emulated(self):

def checkConcurrentUpdates2Storages(self):
self._storage = storage1 = self.openClientStorage()
storage2 = self.openClientStorage()
db1 = DB(storage1)
storage2 = self.openClientStorage()
db2 = DB(storage2)
stop = threading.Event()

Expand Down

0 comments on commit bff1a14

Please sign in to comment.