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
a3a1d169
Commit
a3a1d169
authored
Aug 11, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a possible TypeError in gevent.socket.wait. Fixes #635. Fixes #636.
parent
3696d569
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
changelog.rst
changelog.rst
+2
-0
gevent/_socketcommon.py
gevent/_socketcommon.py
+2
-1
greentest/test__socket.py
greentest/test__socket.py
+24
-0
No files found.
changelog.rst
View file @
a3a1d169
...
...
@@ -20,6 +20,8 @@ Unreleased
with large inputs. `bench_sendall.py`_ now performs about as well on
PyPy as it does on CPython, an improvement of 10x (from ~60MB/s to
~630MB/s). See this `pypy bug`_ for details.
- Fix a possible ``TypeError`` when calling ``gevent.socket.wait``.
Reported in #635 by lanstin.
.. _future: http://python-future.org
.. _bench_sendall.py: https://raw.githubusercontent.com/gevent/gevent/master/greentest/bench_sendall.py
...
...
gevent/_socketcommon.py
View file @
a3a1d169
...
...
@@ -116,6 +116,7 @@ class _NONE(object):
return
"<default value>"
_NONE
=
_NONE
()
_timeout_error
=
timeout
def
wait
(
io
,
timeout
=
None
,
timeout_exc
=
_NONE
):
...
...
@@ -140,7 +141,7 @@ def wait(io, timeout=None, timeout_exc=_NONE):
"""
assert
io
.
callback
is
None
,
'This socket is already used by another greenlet: %r'
%
(
io
.
callback
,
)
if
timeout
is
not
None
:
timeout_exc
=
timeout_exc
if
timeout_exc
is
not
_NONE
else
timeout
(
'timed out'
)
timeout_exc
=
timeout_exc
if
timeout_exc
is
not
_NONE
else
_timeout_error
(
'timed out'
)
timeout
=
Timeout
.
start_new
(
timeout
,
timeout_exc
)
try
:
...
...
greentest/test__socket.py
View file @
a3a1d169
...
...
@@ -222,6 +222,30 @@ class TestCreateConnection(greentest.TestCase):
else
:
raise
AssertionError
(
'create_connection did not raise socket.error as expected'
)
class
TestFunctions
(
greentest
.
TestCase
):
def
test_wait_timeout
(
self
):
# Issue #635
import
gevent.socket
import
gevent._socketcommon
orig_get_hub
=
gevent
.
socket
.
get_hub
class
get_hub
(
object
):
def
wait
(
self
,
io
):
gevent
.
sleep
(
10
)
class
io
(
object
):
callback
=
None
gevent
.
_socketcommon
.
get_hub
=
get_hub
try
:
try
:
gevent
.
socket
.
wait
(
io
(),
timeout
=
0.01
)
except
gevent
.
socket
.
timeout
:
pass
else
:
self
.
fail
(
"Should raise timeout error"
)
finally
:
gevent
.
_socketcommon
.
get_hub
=
orig_get_hub
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