green select: Delete unpatched methods

Explanation in the comment in the code.
This commit is contained in:
Jakub Stasiak
2016-01-07 00:50:01 +01:00
parent 74f418bcf3
commit f63165c0e3
4 changed files with 24 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from eventlet.support import six
__patched__ = ['select']
__deleted__ = ['poll', 'epoll', 'kqueue', 'kevent']
def get_fileno(obj):

View File

@@ -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()

View File

@@ -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')

View File

@@ -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')