equal
deleted
inserted
replaced
27 from __future__ import absolute_import |
27 from __future__ import absolute_import |
28 |
28 |
29 import collections |
29 import collections |
30 import errno |
30 import errno |
31 import math |
31 import math |
32 import platform |
|
33 import select |
32 import select |
34 import socket |
33 import socket |
35 import sys |
34 import sys |
36 import time |
35 import time |
|
36 |
|
37 from . import pycompat |
37 |
38 |
38 namedtuple = collections.namedtuple |
39 namedtuple = collections.namedtuple |
39 Mapping = collections.Mapping |
40 Mapping = collections.Mapping |
40 |
41 |
41 try: |
42 try: |
286 return select.select(r, w, [], timeout) |
287 return select.select(r, w, [], timeout) |
287 |
288 |
288 __all__.append('SelectSelector') |
289 __all__.append('SelectSelector') |
289 |
290 |
290 # Jython has a different implementation of .fileno() for socket objects. |
291 # Jython has a different implementation of .fileno() for socket objects. |
291 if platform.system() == 'Java': |
292 if pycompat.isjython: |
292 class _JythonSelectorMapping(object): |
293 class _JythonSelectorMapping(object): |
293 """ This is an implementation of _SelectorMapping that is built |
294 """ This is an implementation of _SelectorMapping that is built |
294 for use specifically with Jython, which does not provide a hashable |
295 for use specifically with Jython, which does not provide a hashable |
295 value from socket.socket.fileno(). """ |
296 value from socket.socket.fileno(). """ |
296 |
297 |
725 """ This function serves as a first call for DefaultSelector to |
726 """ This function serves as a first call for DefaultSelector to |
726 detect if the select module is being monkey-patched incorrectly |
727 detect if the select module is being monkey-patched incorrectly |
727 by eventlet, greenlet, and preserve proper behavior. """ |
728 by eventlet, greenlet, and preserve proper behavior. """ |
728 global _DEFAULT_SELECTOR |
729 global _DEFAULT_SELECTOR |
729 if _DEFAULT_SELECTOR is None: |
730 if _DEFAULT_SELECTOR is None: |
730 if platform.system() == 'Java': # Platform-specific: Jython |
731 if pycompat.isjython: |
731 _DEFAULT_SELECTOR = JythonSelectSelector |
732 _DEFAULT_SELECTOR = JythonSelectSelector |
732 elif _can_allocate('kqueue'): |
733 elif _can_allocate('kqueue'): |
733 _DEFAULT_SELECTOR = KqueueSelector |
734 _DEFAULT_SELECTOR = KqueueSelector |
734 elif _can_allocate('devpoll'): |
735 elif _can_allocate('devpoll'): |
735 _DEFAULT_SELECTOR = DevpollSelector |
736 _DEFAULT_SELECTOR = DevpollSelector |