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

Method sendall

crates/stdlib/src/socket.rs:1757–1783  ·  view source on GitHub ↗
(
            &self,
            bytes: ArgBytesLike,
            flags: OptionalArg<i32>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1755
1756 #[pymethod]
1757 fn sendall(
1758 &self,
1759 bytes: ArgBytesLike,
1760 flags: OptionalArg<i32>,
1761 vm: &VirtualMachine,
1762 ) -> Result<(), IoOrPyException> {
1763 let flags = flags.unwrap_or(0);
1764
1765 let timeout = self.get_timeout().ok();
1766
1767 let deadline = timeout.map(Deadline::new);
1768
1769 let buf = bytes.borrow_buf();
1770 let buf = &*buf;
1771 let mut buf_offset = 0;
1772 // now we have like 3 layers of interrupt loop :)
1773 while buf_offset < buf.len() {
1774 let interval = deadline.as_ref().map(|d| d.time_until()).transpose()?;
1775 self.sock_op_timeout_err(vm, SelectKind::Write, interval, || {
1776 let subbuf = &buf[buf_offset..];
1777 buf_offset += self.sock()?.send_with_flags(subbuf, flags)?;
1778 Ok(())
1779 })?;
1780 vm.check_signals()?;
1781 }
1782 Ok(())
1783 }
1784
1785 #[pymethod]
1786 fn sendto(

Callers

nothing calls this directly

Calls 10

okMethod · 0.80
get_timeoutMethod · 0.80
time_untilMethod · 0.80
sock_op_timeout_errMethod · 0.80
sockMethod · 0.80
check_signalsMethod · 0.80
mapMethod · 0.45
borrow_bufMethod · 0.45
lenMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected