MCPcopy Index your code
hub / github.com/python/cpython / sock_recv

Method sock_recv

Lib/asyncio/selector_events.py:371–391  ·  view source on GitHub ↗

Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes.

(self, sock, n)

Source from the content-addressed store, hash-verified

369 return self._remove_writer(fd)
370
371 async def sock_recv(self, sock, n):
372 """Receive data from the socket.
373
374 The return value is a bytes object representing the data received.
375 The maximum amount of data to be received at once is specified by
376 nbytes.
377 """
378 base_events._check_ssl_socket(sock)
379 if self._debug and sock.gettimeout() != 0:
380 raise ValueError("the socket must be non-blocking")
381 try:
382 return sock.recv(n)
383 except (BlockingIOError, InterruptedError):
384 pass
385 fut = self.create_future()
386 fd = sock.fileno()
387 self._ensure_fd_no_transport(fd)
388 handle = self._add_reader(fd, self._sock_recv, fut, sock, n)
389 fut.add_done_callback(
390 functools.partial(self._sock_read_done, fd, handle=handle))
391 return await fut
392
393 def _sock_read_done(self, fd, fut, handle=None):
394 if handle is None or not handle.cancelled():

Callers

nothing calls this directly

Calls 8

_add_readerMethod · 0.95
partialMethod · 0.80
gettimeoutMethod · 0.45
recvMethod · 0.45
create_futureMethod · 0.45
filenoMethod · 0.45
add_done_callbackMethod · 0.45

Tested by

no test coverage detected