Skip to content

Commit a23518b

Browse files
committed
PYTHON-5528 Add exponential backoff to operation retry loop for server overloaded errors
(cherry picked from commit 95948d3def875f1efb4d912ab8f507f518604ef5)
1 parent 88f05fa commit a23518b

File tree

5 files changed

+6852
-0
lines changed

5 files changed

+6852
-0
lines changed

.evergreen/resync-specs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ do
9494
change-streams|change_streams)
9595
cpjson change-streams/tests/ change_streams/
9696
;;
97+
client-backpressure|client_backpressure)
98+
cpjson client-backpressure/tests client-backpressure
99+
;;
97100
client-side-encryption|csfle|fle)
98101
cpjson client-side-encryption/tests/ client-side-encryption/spec
99102
cpjson client-side-encryption/corpus/ client-side-encryption/corpus
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2025-present MongoDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
from __future__ import annotations
15+
16+
import os
17+
import sys
18+
19+
sys.path[0:0] = [""]
20+
21+
from test.asynchronous import (
22+
AsyncIntegrationTest,
23+
async_client_context,
24+
unittest,
25+
)
26+
from test.asynchronous.unified_format import generate_test_classes
27+
from test.utils_shared import EventListener, OvertCommandListener
28+
29+
_IS_SYNC = False
30+
31+
32+
class AsyncTestClientBackpressure(AsyncIntegrationTest):
33+
listener: EventListener
34+
35+
@classmethod
36+
def setUpClass(cls) -> None:
37+
cls.listener = OvertCommandListener()
38+
39+
@async_client_context.require_connection
40+
async def asyncSetUp(self) -> None:
41+
await super().asyncSetUp()
42+
self.listener.reset()
43+
self.client = await self.async_rs_or_single_client(
44+
event_listeners=[self.listener], retryWrites=False
45+
)
46+
47+
48+
_TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "client-backpressure")
49+
50+
51+
globals().update(
52+
generate_test_classes(
53+
_TEST_PATH,
54+
module=__name__,
55+
)
56+
)
57+
58+
if __name__ == "__main__":
59+
unittest.main()

0 commit comments

Comments
 (0)