(
sock: Union[socket.socket, _sslConn], length: int
)
| 248 | |
| 249 | |
| 250 | async def async_receive_data_socket( |
| 251 | sock: Union[socket.socket, _sslConn], length: int |
| 252 | ) -> memoryview: |
| 253 | sock_timeout = sock.gettimeout() |
| 254 | timeout = sock_timeout |
| 255 | |
| 256 | sock.settimeout(0.0) |
| 257 | loop = asyncio.get_running_loop() |
| 258 | try: |
| 259 | if _HAVE_SSL and isinstance(sock, (SSLSocket, _sslConn)): |
| 260 | return await asyncio.wait_for( |
| 261 | _async_socket_receive_ssl(sock, length, loop, once=True), # type: ignore[arg-type] |
| 262 | timeout=timeout, |
| 263 | ) |
| 264 | else: |
| 265 | return await asyncio.wait_for( |
| 266 | _async_socket_receive(sock, length, loop), # type: ignore[arg-type] |
| 267 | timeout=timeout, |
| 268 | ) |
| 269 | except asyncio.TimeoutError as err: |
| 270 | raise socket.timeout("timed out") from err |
| 271 | finally: |
| 272 | sock.settimeout(sock_timeout) |
| 273 | |
| 274 | |
| 275 | async def _async_socket_receive( |
no test coverage detected