diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-19 23:45:46 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-19 23:45:46 +0100 |
commit | c067c45212489b83e3f3ebd4bd7df6cf1044aa6e (patch) | |
tree | cae38af706e51b318fa8eef8ff59c6f8c5b2f5c6 | |
parent | 3dc16154337f046a8052fc0e647bbb0f1a80aadc (diff) | |
download | aioeventlet-c067c45212489b83e3f3ebd4bd7df6cf1044aa6e.tar.gz |
aiogreen patchs asyncio/trollius to cancel monkey-patching
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | aiogreen.py | 29 |
2 files changed, 28 insertions, 7 deletions
@@ -31,9 +31,10 @@ Changelog Version 0.2 (development version) --------------------------------- -* Add a suite of automated unit tests -* Support eventlet 0.14 +* Support also eventlet 0.14, not only eventlet 0.15 +* Support eventlet with monkey-patching * sock_connect() is now asynchronous +* Add a suite of automated unit tests 2014-11-19: version 0.1 ----------------------- @@ -77,6 +78,5 @@ Not supported (yet) To do ===== -* Support eventlet with monkey-patching * Glue to ease debug: keep traceback between Handle, coroutine and greenthread. Is it even possible? diff --git a/aiogreen.py b/aiogreen.py index 3cf6362..93ef101 100644 --- a/aiogreen.py +++ b/aiogreen.py @@ -17,13 +17,23 @@ try: from asyncio import selectors from asyncio.base_events import BaseEventLoop from asyncio.base_events import _check_resolved_address + + _FUTURE_CLASSES = (asyncio.Future,) + + if eventlet.patcher.is_monkey_patched('socket'): + # asyncio must use call original functions socket.socket() + # and socket.socketpair() + asyncio.base_events.socket = socket + if sys.platform == 'win32': + asyncio.windows_events.socket = socket + asyncio.windows_utils.socket = socket + else: + asyncio.unix_events.socket = socket + if sys.platform == 'win32': - # FIXME: does it work with eventlet monkey-patching? from asyncio.windows_utils import socketpair else: socketpair = socket.socketpair - - _FUTURE_CLASSES = (asyncio.Future,) except ImportError: import trollius as asyncio from trollius import selector_events @@ -37,8 +47,19 @@ except ImportError: else: # Trollius >= 1.0.1 _FUTURE_CLASSES = asyncio.futures._FUTURE_CLASSES + + if eventlet.patcher.is_monkey_patched('socket'): + # trollius must use call original functions socket.socket() + # and socket.socketpair() + asyncio.base_events.socket = socket + if sys.platform == 'win32': + asyncio.windows_events.socket = socket + asyncio.windows_utils.socket = socket + else: + asyncio.unix_events.socket = socket + # FIXME: patch also trollius.py3_ssl + if sys.platform == 'win32': - # FIXME: does it work with eventlet monkey-patching? from trollius.windows_utils import socketpair else: socketpair = socket.socketpair |