Skip to content

Commit 4e21b63

Browse files
committed
Restore socket timeout after connection + add changelog
1 parent 9ce66b9 commit 4e21b63

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

doc/changelog.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ PyMongo 4.14 brings a number of changes including:
88
- Added :attr:`bson.codec_options.TypeRegistry.codecs` and :attr:`bson.codec_options.TypeRegistry.fallback_encoder` properties
99
to allow users to directly access the type codecs and fallback encoder for a given :class:`bson.codec_options.TypeRegistry`.
1010

11+
Changes in Version 4.13.2 (2025/06/17)
12+
--------------------------------------
13+
14+
Version 4.13.2 is a bug fix release.
15+
16+
- Fixed a bug where ``AsyncMongoClient`` would block the event loop while creating new connections,
17+
potentially significantly increasing latency for ongoing operations.
18+
19+
Issues Resolved
20+
...............
21+
22+
See the `PyMongo 4.13.2 release notes in JIRA`_ for the list of resolved issues
23+
in this release.
24+
25+
.. _PyMongo 4.13.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=43937
26+
27+
1128
Changes in Version 4.13.1 (2025/06/10)
1229
--------------------------------------
1330

pymongo/pool_shared.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,12 @@ async def _async_create_connection(address: _Address, options: PoolOptions) -> s
244244
raise socket.timeout("timed out")
245245
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, True)
246246
_set_keepalive_times(sock)
247+
# Socket needs to be non-blocking during connection to not block the event loop
247248
sock.setblocking(False)
248249
await asyncio.wait_for(
249250
asyncio.get_running_loop().sock_connect(sock, sa), timeout=timeout
250251
)
252+
sock.settimeout(timeout)
251253
return sock
252254
except asyncio.TimeoutError as e:
253255
sock.close()

0 commit comments

Comments
 (0)