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
d6dfeacc
Commit
d6dfeacc
authored
May 25, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backport
b5a218a7
to 1.1 branch.
parent
e8596f4d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
changelog.rst
changelog.rst
+6
-0
gevent/_socket2.py
gevent/_socket2.py
+3
-1
greentest/test__socket.py
greentest/test__socket.py
+17
-3
greentest/test__ssl.py
greentest/test__ssl.py
+4
-0
No files found.
changelog.rst
View file @
d6dfeacc
...
...
@@ -4,6 +4,12 @@
.. currentmodule:: gevent
1.1.2 (TBD)
===========
- Python 2: ``sendall`` on a non-blocking socket could spuriously fail
with a timeout.
1.1.1 (Apr 4, 2016)
===================
...
...
gevent/_socket2.py
View file @
d6dfeacc
...
...
@@ -345,17 +345,19 @@ class socket(object):
"""
data_sent
=
0
len_data_memory
=
len
(
data_memory
)
started_timer
=
0
while
data_sent
<
len_data_memory
:
chunk
=
data_memory
[
data_sent
:]
if
timeleft
is
None
:
data_sent
+=
self
.
send
(
chunk
,
flags
)
elif
timeleft
<=
0
:
elif
started_timer
and
timeleft
<=
0
:
# Check before sending to guarantee a check
# happens even if each chunk successfully sends its data
# (especially important for SSL sockets since they have large
# buffers)
raise
timeout
(
'timed out'
)
else
:
started_timer
=
1
data_sent
+=
self
.
send
(
chunk
,
flags
,
timeout
=
timeleft
)
timeleft
=
end
-
time
.
time
()
...
...
greentest/test__socket.py
View file @
d6dfeacc
...
...
@@ -58,17 +58,21 @@ class TestTCP(greentest.TestCase):
pass
del
self
.
listener
def
create_connection
(
self
,
host
=
'127.0.0.1'
,
port
=
None
,
timeout
=
None
):
def
create_connection
(
self
,
host
=
'127.0.0.1'
,
port
=
None
,
timeout
=
None
,
blocking
=
None
):
sock
=
socket
.
socket
()
sock
.
connect
((
host
,
port
or
self
.
port
))
if
timeout
is
not
None
:
sock
.
settimeout
(
timeout
)
if
blocking
is
not
None
:
sock
.
setblocking
(
blocking
)
return
self
.
_close_on_teardown
(
sock
)
def
_test_sendall
(
self
,
data
,
match_data
=
None
,
client_method
=
'sendall'
,
**
client_args
):
read_data
=
[]
server_exc_info
=
[]
def
accept_and_read
():
try
:
...
...
@@ -78,8 +82,7 @@ class TestTCP(greentest.TestCase):
r
.
close
()
conn
.
close
()
except
:
traceback
.
print_exc
()
os
.
_exit
(
1
)
server_exc_info
.
append
(
sys
.
exc_info
())
server
=
Thread
(
target
=
accept_and_read
)
client
=
self
.
create_connection
(
**
client_args
)
...
...
@@ -95,6 +98,9 @@ class TestTCP(greentest.TestCase):
match_data
=
self
.
long_data
self
.
assertEqual
(
read_data
[
0
],
match_data
)
if
server_exc_info
:
six
.
reraise
(
*
server_exc_info
[
0
])
def
test_sendall_str
(
self
):
self
.
_test_sendall
(
self
.
long_data
)
...
...
@@ -115,6 +121,14 @@ class TestTCP(greentest.TestCase):
data
=
b''
self
.
_test_sendall
(
data
,
data
,
timeout
=
10
)
def
test_sendall_nonblocking
(
self
):
# https://github.com/benoitc/gunicorn/issues/1282
# Even if the socket is non-blocking, we make at least
# one attempt to send data. Under Py2 before this fix, we
# would incorrectly immediately raise a timeout error
data
=
b'hi
\
n
'
self
.
_test_sendall
(
data
,
data
,
blocking
=
False
)
def
test_empty_send
(
self
):
# Issue 719
data
=
b''
...
...
greentest/test__ssl.py
View file @
d6dfeacc
...
...
@@ -66,6 +66,10 @@ class TestSSL(test__socket.TestTCP):
b''
,
client_method
=
'send'
)
def
test_sendall_nonblocking
(
self
):
# Override; doesn't work with SSL sockets.
pass
def
ssl_listener
(
address
,
private_key
,
certificate
):
raw_listener
=
socket
.
socket
()
...
...
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