1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
"""
asyncio submodules continue to have the original, real socket module even after
monkeypatching.
"""
import sys
def assert_correct_patching():
from eventlet.greenio.base import GreenSocket
import asyncio.selector_events
if asyncio.selector_events.socket.socket is GreenSocket:
raise RuntimeError("Wrong socket class, should've been normal socket.socket")
import asyncio.selector_events
if asyncio.selector_events.selectors is not sys.modules["__original_module_selectors"]:
raise RuntimeError("Wrong selectors")
if asyncio.selector_events.selectors.select is not sys.modules["__original_module_select"]:
raise RuntimeError("Wrong select")
import eventlet.hubs
eventlet.hubs.get_hub()
assert_correct_patching()
import eventlet
eventlet.monkey_patch()
assert_correct_patching()
print("pass")
|