(sock: Union[socket.socket, _sslConn], buf: bytes)
| 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 |
| 75 | async 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 | |
| 91 | if sys.platform != "win32": |
no test coverage detected