Skip to content

Commit

Permalink
Merge pull request #73 from zopefoundation/uvloop-support-in-mtacceotor
Browse files Browse the repository at this point in the history
Got uvloop working with the mtacceptor
  • Loading branch information
jimfulton committed Aug 13, 2016
2 parents 49bc8e4 + e439b57 commit beb5086
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 35 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def emit(self, record):
classifiers = classifiers,
test_suite="__main__.alltests", # to support "setup.py test"
tests_require = tests_require,
extras_require = dict(test=tests_require, uvloop=['uvloop']),
extras_require = dict(test=tests_require, uvloop=['uvloop >=0.5.1']),
install_requires = install_requires,
zip_safe = False,
entry_points = """
Expand Down
13 changes: 1 addition & 12 deletions src/ZEO/asyncio/client.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
from .._compat import PY3

if PY3:
import asyncio
try:
from uvloop import new_event_loop
except ImportError:
from asyncio import new_event_loop
else:
import trollius as asyncio
from trollius import new_event_loop

from ZEO.Exceptions import ClientDisconnected, ServerException
import concurrent.futures
import functools
Expand All @@ -24,6 +12,7 @@
import ZEO.interfaces

from . import base
from .compat import asyncio, new_event_loop
from .marshal import decode

logger = logging.getLogger(__name__)
Expand Down
10 changes: 10 additions & 0 deletions src/ZEO/asyncio/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .._compat import PY3
if PY3:
import asyncio
try:
from uvloop import new_event_loop
except ImportError:
from asyncio import new_event_loop
else:
import trollius as asyncio
from trollius import new_event_loop
13 changes: 3 additions & 10 deletions src/ZEO/asyncio/mtacceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@
in ZEO.StorageServer.
"""
from .._compat import PY3

if PY3:
import asyncio
else:
import trollius as asyncio

import asyncore
import socket
import threading
import time

from .compat import asyncio, new_event_loop
from .server import ServerProtocol

# _has_dualstack: True if the dual-stack sockets are supported
Expand Down Expand Up @@ -169,8 +163,7 @@ def handle_accept(self):
logger.debug("new connection %s" % (addr,))

def run():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop = new_event_loop()
zs = self.storage_server.create_client_handler()
protocol = ServerProtocol(loop, self.addr, zs)
protocol.stop = loop.stop
Expand All @@ -179,7 +172,7 @@ def run():
cr = loop.create_connection((lambda : protocol), sock=sock)
else:
if hasattr(loop, 'connect_accepted_socket'):
loop.connect_accepted_socket(
cr = loop.connect_accepted_socket(
(lambda : protocol), sock, ssl=self.ssl_context)
else:
#######################################################
Expand Down
13 changes: 1 addition & 12 deletions src/ZEO/asyncio/server.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
from .._compat import PY3

if PY3:
import asyncio
try:
from uvloop import new_event_loop
except ImportError:
from asyncio import new_event_loop
else:
import trollius as asyncio
from trollius import new_event_loop

import json
import logging
import os
Expand All @@ -22,6 +10,7 @@
from ..shortrepr import short_repr

from . import base
from .compat import asyncio, new_event_loop
from .marshal import server_decode

class ServerProtocol(base.Protocol):
Expand Down

0 comments on commit beb5086

Please sign in to comment.