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

Method sock_recvfrom

Lib/asyncio/selector_events.py:451–472  ·  view source on GitHub ↗

Receive a datagram from a datagram socket. The return value is a tuple of (bytes, address) representing the datagram received and the address it came from. The maximum amount of data to be received at once is specified by nbytes.

(self, sock, bufsize)

Source from the content-addressed store, hash-verified

449 fut.set_result(nbytes)
450
451 async def sock_recvfrom(self, sock, bufsize):
452 """Receive a datagram from a datagram socket.
453
454 The return value is a tuple of (bytes, address) representing the
455 datagram received and the address it came from.
456 The maximum amount of data to be received at once is specified by
457 nbytes.
458 """
459 base_events._check_ssl_socket(sock)
460 if self._debug and sock.gettimeout() != 0:
461 raise ValueError("the socket must be non-blocking")
462 try:
463 return sock.recvfrom(bufsize)
464 except (BlockingIOError, InterruptedError):
465 pass
466 fut = self.create_future()
467 fd = sock.fileno()
468 self._ensure_fd_no_transport(fd)
469 handle = self._add_reader(fd, self._sock_recvfrom, fut, sock, bufsize)
470 fut.add_done_callback(
471 functools.partial(self._sock_read_done, fd, handle=handle))
472 return await fut
473
474 def _sock_recvfrom(self, fut, sock, bufsize):
475 # _sock_recvfrom() can add itself as an I/O callback if the operation

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected