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
08080428
Commit
08080428
authored
Jul 21, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport fix for #835.
parent
ee9f6785
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
+35
-5
changelog.rst
changelog.rst
+3
-0
gevent/monkey.py
gevent/monkey.py
+11
-5
greentest/test__monkey_selectors.py
greentest/test__monkey_selectors.py
+21
-0
No files found.
changelog.rst
View file @
08080428
...
...
@@ -10,6 +10,9 @@
- Python 2: ``sendall`` on a non-blocking socket could spuriously fail
with a timeout.
- Fix :issue:`825`.
- :class:`selectors.SelectSelector` is properly monkey-patched
regardless of the order of imports. Reported in :issue:`835` by
Przemysław Węgrzyn.
1.1.1 (Apr 4, 2016)
===================
...
...
gevent/monkey.py
View file @
08080428
...
...
@@ -468,12 +468,18 @@ def patch_select(aggressive=True):
# 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
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'
)
if
selectors
.
SelectSelector
.
_select
is
select
.
select
:
def
_select
(
self
,
*
args
,
**
kwargs
):
return
select
.
select
(
*
args
,
**
kwargs
)
selectors
.
SelectSelector
.
_select
=
_select
if
selectors
.
SelectSelector
.
_select
in
(
select
.
select
,
orig_select_select
):
def
_select
(
self
,
*
args
,
**
kwargs
):
# pylint:disable=unused-argument
return
select
.
select
(
*
args
,
**
kwargs
)
selectors
.
SelectSelector
.
_select
=
_select
_select
.
_gevent_monkey
=
True
if
aggressive
:
# If `selectors` had already been imported before we removed
...
...
greentest/test__monkey_selectors.py
0 → 100644
View file @
08080428
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