Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
d099423c
Commit
d099423c
authored
Jan 16, 2020
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests on windows, where SelectSelector._select is a normal method.
parent
3d4404d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
114 deletions
+128
-114
src/gevent/select.py
src/gevent/select.py
+125
-114
src/gevent/tests/test__monkey_selectors.py
src/gevent/tests/test__monkey_selectors.py
+3
-0
No files found.
src/gevent/select.py
View file @
d099423c
...
...
@@ -28,14 +28,17 @@ else:
try
:
from
select
import
poll
as
original_poll
from
select
import
POLLIN
,
POLLOUT
,
POLLNVAL
__implements__
=
[
'select'
,
'poll'
]
except
ImportError
:
original_poll
=
None
POLLIN
=
1
POLLOUT
=
4
POLLNVAL
=
32
__implements__
=
[
'select'
]
__all__
=
[
'error'
]
+
__implements__
if
'poll'
not
in
__all__
:
__all__
.
append
(
'poll'
)
import
select
as
__select__
...
...
@@ -184,8 +187,8 @@ def select(rlist, wlist, xlist, timeout=None): # pylint:disable=unused-argument
return
result
.
select
(
rlist
,
wlist
,
timeout
)
if
original_poll
is
not
None
:
class
PollResult
(
object
):
class
PollResult
(
object
):
__slots__
=
(
'events'
,
'event'
)
def
__init__
(
self
):
...
...
@@ -205,13 +208,17 @@ if original_poll is not None:
self
.
events
.
add
((
fd
,
result_flags
))
self
.
event
.
set
()
class
poll
(
object
):
class
poll
(
object
):
"""
An implementation of :class:`select.poll` that blocks only the current greenlet.
.. caution:: ``POLLPRI`` data is not supported.
.. versionadded:: 1.1b1
.. versionchanged:: 1.5
This is now always defined, regardless of whether the standard library
defines :func:`select.poll` or not. Note that it may have different performance
characteristics.
"""
def
__init__
(
self
):
# {int -> flags}
...
...
@@ -298,8 +305,6 @@ if original_poll is not None:
fileno
=
get_fileno
(
fd
)
del
self
.
fds
[
fileno
]
del
original_poll
def
_gevent_do_monkey_patch
(
patch_request
):
aggressive
=
patch_request
.
patch_kwargs
[
'aggressive'
]
...
...
@@ -323,13 +328,19 @@ def _gevent_do_monkey_patch(patch_request):
# package? If so, must be careful to deal with DoNotPatch exceptions.
# Python 3 wants to use `select.select` as a member function,
# leading to this error in selectors.py (because gevent.select.select is
# not a builtin and doesn't get the magic auto-static that they do)
# leading to this error in selectors.py (because
# gevent.select.select is not a builtin and doesn't get the
# magic auto-static that they do):
#
# r, w, _ = self._select(self._readers, self._writers, [], timeout)
# TypeError: select() takes from 3 to 4 positional arguments but 5 were given
# Note that this obviously only happens if selectors was imported after we had patched
# select; but there is a code path that leads to it being imported first (but now we've
# patched select---so we can't compare them identically)
#
# Note that this obviously only happens if selectors was
# imported after we had patched select; but there is a code
# path that leads to it being imported first (but now we've
# patched select---so we can't compare them identically). It also doesn't
# happen on Windows, because they define a normal method for _select, to work around
# some weirdness in the handling of the third argument.
orig_select_select
=
patch_request
.
get_original
(
'select'
,
'select'
)
assert
target_mod
.
select
is
not
orig_select_select
...
...
src/gevent/tests/test__monkey_selectors.py
View file @
d099423c
...
...
@@ -21,6 +21,9 @@ patch_all()
)
class
TestSelectors
(
greentest
.
TestCase
):
@
greentest
.
skipOnWindows
(
"SelectSelector._select is a normal function on Windows"
)
def
test_selectors_select_is_patched
(
self
):
# https://github.com/gevent/gevent/issues/835
_select
=
selectors
.
SelectSelector
.
_select
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment