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

Method sock_sendall

Lib/asyncio/selector_events.py:533–562  ·  view source on GitHub ↗

Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determ

(self, sock, data)

Source from the content-addressed store, hash-verified

531 fut.set_result(result)
532
533 async def sock_sendall(self, sock, data):
534 """Send data to the socket.
535
536 The socket must be connected to a remote socket. This method continues
537 to send data from data until either all data has been sent or an
538 error occurs. None is returned on success. On error, an exception is
539 raised, and there is no way to determine how much data, if any, was
540 successfully processed by the receiving end of the connection.
541 """
542 base_events._check_ssl_socket(sock)
543 if self._debug and sock.gettimeout() != 0:
544 raise ValueError("the socket must be non-blocking")
545 try:
546 n = sock.send(data)
547 except (BlockingIOError, InterruptedError):
548 n = 0
549
550 if n == len(data):
551 # all data sent
552 return
553
554 fut = self.create_future()
555 fd = sock.fileno()
556 self._ensure_fd_no_transport(fd)
557 # use a trick with a list in closure to store a mutable state
558 handle = self._add_writer(fd, self._sock_sendall, fut, sock,
559 memoryview(data), [n])
560 fut.add_done_callback(
561 functools.partial(self._sock_write_done, fd, handle=handle))
562 return await fut
563
564 def _sock_sendall(self, fut, sock, view, pos):
565 if fut.done():

Callers

nothing calls this directly

Calls 8

_add_writerMethod · 0.95
partialMethod · 0.80
gettimeoutMethod · 0.45
sendMethod · 0.45
create_futureMethod · 0.45
filenoMethod · 0.45
add_done_callbackMethod · 0.45

Tested by

no test coverage detected