MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / async_socket_sendall

Function async_socket_sendall

pymongo/network_layer.py:75–88  ·  view source on GitHub ↗
(sock: Union[socket.socket, _sslConn], buf: bytes)

Source from the content-addressed store, hash-verified

73# These socket-based I/O methods are for KMS requests and any other network operations that do not use
74# the MongoDB wire protocol
75async def async_socket_sendall(sock: Union[socket.socket, _sslConn], buf: bytes) -> None:
76 timeout = sock.gettimeout()
77 sock.settimeout(0.0)
78 loop = asyncio.get_running_loop()
79 try:
80 if _HAVE_SSL and isinstance(sock, (SSLSocket, _sslConn)):
81 await asyncio.wait_for(_async_socket_sendall_ssl(sock, buf, loop), timeout=timeout)
82 else:
83 await asyncio.wait_for(loop.sock_sendall(sock, buf), timeout=timeout) # type: ignore[arg-type]
84 except asyncio.TimeoutError as exc:
85 # Convert the asyncio.wait_for timeout error to socket.timeout which pool.py understands.
86 raise socket.timeout("timed out") from exc
87 finally:
88 sock.settimeout(timeout)
89
90
91if sys.platform != "win32":

Callers 1

kms_requestMethod · 0.90

Calls 5

wait_forMethod · 0.80
gettimeoutMethod · 0.45
settimeoutMethod · 0.45
timeoutMethod · 0.45

Tested by

no test coverage detected