Commit 564a7fa6 authored by Denis Bilenko's avatar Denis Bilenko

server: fix do_read() enough to run bench_sendall() PY3

parent 4c173c7d
......@@ -125,6 +125,7 @@ class socket(_socket.socket):
# Python Issue #7995: if no default timeout is set and the listening
# socket had a (non-zero) timeout, force the new socket in blocking
# mode to override platform-specific socket flags inheritance.
# XXX do we need to do this?
if getdefaulttimeout() is None and self.gettimeout():
sock.setblocking(True)
return sock, addr
......
......@@ -4,7 +4,9 @@ import sys
import _socket
from gevent.baseserver import BaseServer
from gevent.socket import EWOULDBLOCK, socket
from gevent.hub import PYPY
from gevent.hub import PYPY, PY3
if PY3:
from io import BlockingIOError
__all__ = ['StreamServer', 'DatagramServer']
......@@ -89,17 +91,33 @@ class StreamServer(BaseServer):
backlog = self.backlog
return _tcp_listener(address, backlog=backlog, reuse_addr=self.reuse_addr, family=family)
def do_read(self):
try:
client_socket, address = self.socket.accept()
except _socket.error as err:
if err.args[0] == EWOULDBLOCK:
return
raise
sockobj = socket(_sock=client_socket)
if PYPY:
client_socket._drop()
return sockobj, address
if PY3:
def do_read(self):
sock = self.socket
try:
fd, address = sock._accept()
except BlockingIOError:
if sock.timeout == 0.0:
return
raise
sock = socket(sock.family, sock.type, sock.proto, fileno=fd)
# XXX Python issue #7995?
return sock, address
else:
def do_read(self):
try:
client_socket, address = self.socket.accept()
except _socket.error as err:
if err.args[0] == EWOULDBLOCK:
return
raise
sockobj = socket(_sock=client_socket)
if PYPY:
client_socket._drop()
return sockobj, address
def do_close(self, socket, *args):
socket.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment