green select: Delete unpatched methods
Explanation in the comment in the code.
This commit is contained in:
@@ -6,6 +6,7 @@ from eventlet.support import six
|
||||
|
||||
|
||||
__patched__ = ['select']
|
||||
__deleted__ = ['poll', 'epoll', 'kqueue', 'kevent']
|
||||
|
||||
|
||||
def get_fileno(obj):
|
||||
|
@@ -295,6 +295,10 @@ def monkey_patch(**on):
|
||||
patched_attr = getattr(mod, attr_name, None)
|
||||
if patched_attr is not None:
|
||||
setattr(orig_mod, attr_name, patched_attr)
|
||||
deleted = getattr(mod, '__deleted__', [])
|
||||
for attr_name in deleted:
|
||||
if hasattr(orig_mod, attr_name):
|
||||
delattr(orig_mod, attr_name)
|
||||
finally:
|
||||
imp.release_lock()
|
||||
|
||||
|
@@ -0,0 +1,15 @@
|
||||
if __name__ == '__main__':
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
# Leaving unpatched select methods in the select module is a recipe
|
||||
# for trouble and this test makes sure we don't do that.
|
||||
#
|
||||
# Issues:
|
||||
# * https://bitbucket.org/eventlet/eventlet/issues/167
|
||||
# * https://github.com/eventlet/eventlet/issues/169
|
||||
import select
|
||||
for name in ['poll', 'epoll', 'kqueue', 'kevent']:
|
||||
assert not hasattr(select, name), name
|
||||
|
||||
print('pass')
|
@@ -510,3 +510,7 @@ def test_threading_join():
|
||||
|
||||
def test_socketserver_selectors():
|
||||
tests.run_isolated('patcher_socketserver_selectors.py')
|
||||
|
||||
|
||||
def test_blocking_select_methods_are_deleted():
|
||||
tests.run_isolated('patcher_blocking_select_methods_are_deleted.py')
|
||||
|
Reference in New Issue
Block a user