Files
deb-python-eventlet/eventlet/green/selectors.py
Jakub Stasiak 16aa6cb370 green selectors: Override DefaultSelector as well
The original patch[1] missed one thing which I just discovered - there's
selectors.DefaultSelector alias for the "the most efficient implementation
available on the current platform"[2].

Before this patch a non-green selector class would be obtained when
DefaultSelector was used.

[1] 0d509ef7d2
[2] https://docs.python.org/3.5/library/selectors.html#selectors.DefaultSelector
2016-01-11 22:25:15 +01:00

35 lines
948 B
Python

import sys
from eventlet import patcher
from eventlet.green import select
__patched__ = [
'DefaultSelector',
'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',
'EpollSelector',
'DevpollSelector',
'KqueueSelector',
]
patcher.inject('selectors', globals(), ('select', select))
del patcher
if sys.platform != 'win32':
SelectSelector._select = staticmethod(select.select)
DefaultSelector = SelectSelector