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
4b3fba8a
Commit
4b3fba8a
authored
Jul 21, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #835. patch_select deals better with unexpected import order.
parent
80f014ee
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
changelog.rst
changelog.rst
+3
-0
src/gevent/monkey.py
src/gevent/monkey.py
+8
-2
src/greentest/test__monkey_selectors.py
src/greentest/test__monkey_selectors.py
+22
-0
No files found.
changelog.rst
View file @
4b3fba8a
...
@@ -69,6 +69,9 @@ Stdlib Compatibility
...
@@ -69,6 +69,9 @@ Stdlib Compatibility
libev would tend to return the descriptor as ready. In the worst
libev would tend to return the descriptor as ready. In the worst
case, this adds an extra system call, but may also reduce latency if
case, this adds an extra system call, but may also reduce latency if
descriptors are ready at the time of entry.
descriptors are ready at the time of entry.
- :class:`selectors.SelectSelector` is properly monkey-patched
regardless of the order of imports. Reported in :issue:`835` by
Przemysław Węgrzyn.
- :meth:`gevent.select.poll.unregister` raises an exception if *fd* is not
- :meth:`gevent.select.poll.unregister` raises an exception if *fd* is not
registered, like the standard library.
registered, like the standard library.
- :meth:`gevent.select.poll.poll` returns an event with
- :meth:`gevent.select.poll.poll` returns an event with
...
...
src/gevent/monkey.py
View file @
4b3fba8a
...
@@ -495,12 +495,18 @@ def patch_select(aggressive=True):
...
@@ -495,12 +495,18 @@ def patch_select(aggressive=True):
# not a builtin and doesn't get the magic auto-static that they do)
# not a builtin and doesn't get the magic auto-static that they do)
# r, w, _ = self._select(self._readers, self._writers, [], timeout)
# r, w, _ = self._select(self._readers, self._writers, [], timeout)
# TypeError: select() takes from 3 to 4 positional arguments but 5 were given
# TypeError: select() takes from 3 to 4 positional arguments but 5 were given
select
=
__import__
(
'select'
)
# 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)
select
=
__import__
(
'select'
)
# Should be gevent-patched now
orig_select_select
=
get_original
(
'select'
,
'select'
)
assert
select
.
select
is
not
orig_select_select
selectors
=
__import__
(
'selectors'
)
selectors
=
__import__
(
'selectors'
)
if
selectors
.
SelectSelector
.
_select
i
s
select
.
select
:
if
selectors
.
SelectSelector
.
_select
i
n
(
select
.
select
,
orig_select_select
)
:
def
_select
(
self
,
*
args
,
**
kwargs
):
# pylint:disable=unused-argument
def
_select
(
self
,
*
args
,
**
kwargs
):
# pylint:disable=unused-argument
return
select
.
select
(
*
args
,
**
kwargs
)
return
select
.
select
(
*
args
,
**
kwargs
)
selectors
.
SelectSelector
.
_select
=
_select
selectors
.
SelectSelector
.
_select
=
_select
_select
.
_gevent_monkey
=
True
if
aggressive
:
if
aggressive
:
# If `selectors` had already been imported before we removed
# If `selectors` had already been imported before we removed
...
...
src/greentest/test__monkey_selectors.py
0 → 100644
View file @
4b3fba8a
import
sys
import
greentest
try
:
import
selectors
# Do this before the patch, just to force it
except
ImportError
:
pass
from
gevent.monkey
import
patch_all
patch_all
()
if
sys
.
platform
!=
'win32'
and
sys
.
version_info
[:
2
]
>=
(
3
,
4
):
class
TestSelectors
(
greentest
.
TestCase
):
def
test_selectors_select_is_patched
(
self
):
# https://github.com/gevent/gevent/issues/835
_select
=
selectors
.
SelectSelector
.
_select
self
.
assertTrue
(
hasattr
(
_select
,
'_gevent_monkey'
),
dir
(
_select
))
if
__name__
==
'__main__'
:
greentest
.
main
()
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