Skip to content

Commit 666ee49

Browse files
committed
Don't try to read right away in sock_recv
After collecting some stats, it looks like reading without select is almost never successful.
1 parent 47971d6 commit 666ee49

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

uvloop/loop.pyx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ cdef class Loop:
16201620
"""Remove a writer callback."""
16211621
self._remove_writer(fd)
16221622

1623-
async def sock_recv(self, sock, n):
1623+
def sock_recv(self, sock, n):
16241624
"""Receive data from the socket.
16251625
16261626
The return value is a bytes object representing the data received.
@@ -1631,19 +1631,9 @@ cdef class Loop:
16311631
"""
16321632
if self._debug and sock.gettimeout() != 0:
16331633
raise ValueError("the socket must be non-blocking")
1634-
1635-
try:
1636-
data = sock.recv(n)
1637-
except (BlockingIOError, InterruptedError):
1638-
pass
1639-
else:
1640-
IF DEBUG:
1641-
self._sock_try_read_total += 1
1642-
return data
1643-
16441634
fut = self._new_future()
16451635
self._sock_recv(fut, 0, sock, n)
1646-
return await fut
1636+
return fut
16471637

16481638
async def sock_sendall(self, sock, data):
16491639
"""Send data to the socket.

0 commit comments

Comments
 (0)