green selectors: Remove non-green selectors
The code pretending that all the selector classes exist and "implementing" them using SelectSelector was added in [1] because there was no facility to easily remove things from green version of modules (as far as I understand) - the facility has been added in [2] thus allowing us to make this change. As mentioned in the code I believe this approach is likely to be less confusing than the previous one (SelectSelector doesn't expose fileno() method that the other selectors have so it's not fully API-compatible with them). [1]0d509ef7d2
[2]f63165c0e3
This commit is contained in:
@@ -5,6 +5,18 @@ from eventlet.green import select
|
|||||||
|
|
||||||
__patched__ = [
|
__patched__ = [
|
||||||
'SelectSelector',
|
'SelectSelector',
|
||||||
|
]
|
||||||
|
|
||||||
|
# We only have green select so the options are:
|
||||||
|
# * leave it be and have selectors that block
|
||||||
|
# * try to pretend the "bad" selectors don't exist
|
||||||
|
# * replace all with SelectSelector for the price of possibly different
|
||||||
|
# performance characteristic and missing fileno() method (if someone
|
||||||
|
# uses it it'll result in a crash, we may want to implement it in the future)
|
||||||
|
#
|
||||||
|
# This module used to follow the third approach but just removing the offending
|
||||||
|
# selectors is less error prone and less confusing approach.
|
||||||
|
__deleted__ = [
|
||||||
'PollSelector',
|
'PollSelector',
|
||||||
'EpollSelector',
|
'EpollSelector',
|
||||||
'DevpollSelector',
|
'DevpollSelector',
|
||||||
@@ -17,15 +29,3 @@ del patcher
|
|||||||
|
|
||||||
if sys.platform != 'win32':
|
if sys.platform != 'win32':
|
||||||
SelectSelector._select = staticmethod(select.select)
|
SelectSelector._select = staticmethod(select.select)
|
||||||
|
|
||||||
|
|
||||||
# We only have green select so the options are:
|
|
||||||
# * leave it be and have selectors that block
|
|
||||||
# * try to pretend the "bad" selectors don't exist
|
|
||||||
# * replace all with SelectSelector for the price of possibly different
|
|
||||||
# performance characteristic and missing fileno() method (if someone
|
|
||||||
# uses it it'll result in a crash, we may want to implement it in the future)
|
|
||||||
PollSelector = SelectSelector
|
|
||||||
EpollSelector = SelectSelector
|
|
||||||
DevpollSelector = SelectSelector
|
|
||||||
KqueueSelector = SelectSelector
|
|
||||||
|
@@ -12,4 +12,16 @@ if __name__ == '__main__':
|
|||||||
for name in ['poll', 'epoll', 'kqueue', 'kevent']:
|
for name in ['poll', 'epoll', 'kqueue', 'kevent']:
|
||||||
assert not hasattr(select, name), name
|
assert not hasattr(select, name), name
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 4):
|
||||||
|
import selectors
|
||||||
|
for name in [
|
||||||
|
'PollSelector',
|
||||||
|
'EpollSelector',
|
||||||
|
'DevpollSelector',
|
||||||
|
'KqueueSelector',
|
||||||
|
]:
|
||||||
|
assert not hasattr(selectors, name), name
|
||||||
|
|
||||||
print('pass')
|
print('pass')
|
||||||
|
Reference in New Issue
Block a user