Commit beb50865 authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #73 from zopefoundation/uvloop-support-in-mtacceotor

Got uvloop working with the mtacceptor
parents 49bc8e46 e439b578
...@@ -128,7 +128,7 @@ setup(name="ZEO", ...@@ -128,7 +128,7 @@ setup(name="ZEO",
classifiers = classifiers, classifiers = classifiers,
test_suite="__main__.alltests", # to support "setup.py test" test_suite="__main__.alltests", # to support "setup.py test"
tests_require = tests_require, 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, install_requires = install_requires,
zip_safe = False, zip_safe = False,
entry_points = """ entry_points = """
......
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 from ZEO.Exceptions import ClientDisconnected, ServerException
import concurrent.futures import concurrent.futures
import functools import functools
...@@ -24,6 +12,7 @@ import ZEO.Exceptions ...@@ -24,6 +12,7 @@ import ZEO.Exceptions
import ZEO.interfaces import ZEO.interfaces
from . import base from . import base
from .compat import asyncio, new_event_loop
from .marshal import decode from .marshal import decode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
......
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
...@@ -41,18 +41,12 @@ with:: ...@@ -41,18 +41,12 @@ with::
in ZEO.StorageServer. in ZEO.StorageServer.
""" """
from .._compat import PY3
if PY3:
import asyncio
else:
import trollius as asyncio
import asyncore import asyncore
import socket import socket
import threading import threading
import time import time
from .compat import asyncio, new_event_loop
from .server import ServerProtocol from .server import ServerProtocol
# _has_dualstack: True if the dual-stack sockets are supported # _has_dualstack: True if the dual-stack sockets are supported
...@@ -169,8 +163,7 @@ class Acceptor(asyncore.dispatcher): ...@@ -169,8 +163,7 @@ class Acceptor(asyncore.dispatcher):
logger.debug("new connection %s" % (addr,)) logger.debug("new connection %s" % (addr,))
def run(): def run():
loop = asyncio.new_event_loop() loop = new_event_loop()
asyncio.set_event_loop(loop)
zs = self.storage_server.create_client_handler() zs = self.storage_server.create_client_handler()
protocol = ServerProtocol(loop, self.addr, zs) protocol = ServerProtocol(loop, self.addr, zs)
protocol.stop = loop.stop protocol.stop = loop.stop
...@@ -179,7 +172,7 @@ class Acceptor(asyncore.dispatcher): ...@@ -179,7 +172,7 @@ class Acceptor(asyncore.dispatcher):
cr = loop.create_connection((lambda : protocol), sock=sock) cr = loop.create_connection((lambda : protocol), sock=sock)
else: else:
if hasattr(loop, 'connect_accepted_socket'): if hasattr(loop, 'connect_accepted_socket'):
loop.connect_accepted_socket( cr = loop.connect_accepted_socket(
(lambda : protocol), sock, ssl=self.ssl_context) (lambda : protocol), sock, ssl=self.ssl_context)
else: else:
####################################################### #######################################################
......
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 json
import logging import logging
import os import os
...@@ -22,6 +10,7 @@ logger = logging.getLogger(__name__) ...@@ -22,6 +10,7 @@ logger = logging.getLogger(__name__)
from ..shortrepr import short_repr from ..shortrepr import short_repr
from . import base from . import base
from .compat import asyncio, new_event_loop
from .marshal import server_decode from .marshal import server_decode
class ServerProtocol(base.Protocol): class ServerProtocol(base.Protocol):
......
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