MCPcopy Index your code
hub / github.com/RustPython/RustPython / sock_recv

Method sock_recv

Lib/asyncio/selector_events.py:368–388  ·  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

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