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

Function async_receive_data_socket

pymongo/network_layer.py:250–272  ·  view source on GitHub ↗
(
    sock: Union[socket.socket, _sslConn], length: int
)

Source from the content-addressed store, hash-verified

248
249
250async 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
275async def _async_socket_receive(

Callers 1

kms_requestMethod · 0.90

Calls 6

_async_socket_receiveFunction · 0.85
wait_forMethod · 0.80
gettimeoutMethod · 0.45
settimeoutMethod · 0.45
timeoutMethod · 0.45

Tested by

no test coverage detected