Skip to content

Commit 0696cf8

Browse files
committed
append details to MaxTimeMSExpired responses
1 parent 088b653 commit 0696cf8

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

pymongo/asynchronous/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
_SDAMStatusMessage,
3939
)
4040
from pymongo.message import _convert_exception, _GetMore, _OpMsg, _Query
41+
from pymongo.pool_shared import _get_timeout_details, format_timeout_details
4142
from pymongo.response import PinnedResponse, Response
4243

4344
if TYPE_CHECKING:
@@ -224,6 +225,10 @@ async def run_operation(
224225
if use_cmd:
225226
first = docs[0]
226227
await operation.client._process_response(first, operation.session) # type: ignore[misc, arg-type]
228+
# Append timeout details to MaxTimeMSExpired responses.
229+
if first.get("code") == 50:
230+
timeout_details = _get_timeout_details(conn.opts)
231+
first["errmsg"] += format_timeout_details(timeout_details)
227232
_check_command_response(first, conn.max_wire_version)
228233
except Exception as exc:
229234
duration = datetime.now() - start

pymongo/synchronous/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
_SDAMStatusMessage,
3838
)
3939
from pymongo.message import _convert_exception, _GetMore, _OpMsg, _Query
40+
from pymongo.pool_shared import _get_timeout_details, format_timeout_details
4041
from pymongo.response import PinnedResponse, Response
4142
from pymongo.synchronous.helpers import _handle_reauth
4243

@@ -224,6 +225,10 @@ def run_operation(
224225
if use_cmd:
225226
first = docs[0]
226227
operation.client._process_response(first, operation.session) # type: ignore[misc, arg-type]
228+
# Append timeout details to MaxTimeMSExpired responses.
229+
if first.get("code") == 50:
230+
timeout_details = _get_timeout_details(conn.opts)
231+
first["errmsg"] += format_timeout_details(timeout_details)
227232
_check_command_response(first, conn.max_wire_version)
228233
except Exception as exc:
229234
duration = datetime.now() - start

test/asynchronous/test_pooling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ async def find_one():
429429
# maxConnecting = unbounded: 30+ connections in ~0.140+ seconds
430430
print(len(pool.conns))
431431

432-
@flaky(reason="PYTHON-5492", affects_cpython_linux=True)
433432
@async_client_context.require_failCommand_appName
434433
async def test_csot_timeout_message(self):
435434
client = await self.async_rs_or_single_client(appName="connectionTimeoutApp")

test/test_pooling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ def find_one():
429429
# maxConnecting = unbounded: 30+ connections in ~0.140+ seconds
430430
print(len(pool.conns))
431431

432-
@flaky(reason="PYTHON-5492", affects_cpython_linux=True)
433432
@client_context.require_failCommand_appName
434433
def test_csot_timeout_message(self):
435434
client = self.rs_or_single_client(appName="connectionTimeoutApp")

0 commit comments

Comments
 (0)