Skip to content

Commit 9ce66b9

Browse files
committed
Fix asyncio.TimeoutError handling
1 parent 9bb2e6d commit 9ce66b9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pymongo/pool_shared.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,12 @@ async def _async_create_connection(address: _Address, options: PoolOptions) -> s
249249
asyncio.get_running_loop().sock_connect(sock, sa), timeout=timeout
250250
)
251251
return sock
252-
except (OSError, asyncio.TimeoutError) as e:
253-
err = e
252+
except asyncio.TimeoutError as e:
253+
sock.close()
254+
raise socket.timeout("timed out") from e
255+
except OSError as e:
254256
sock.close()
257+
err = e
255258

256259
if err is not None:
257260
raise err

0 commit comments

Comments
 (0)