|
35 | 35 | from unittest import SkipTest |
36 | 36 |
|
37 | 37 | from bson.son import SON |
38 | | -from pymongo import common, message |
| 38 | +from pymongo import message |
39 | 39 | from pymongo.ssl_support import HAVE_SSL, _ssl # type:ignore[attr-defined] |
40 | 40 | from pymongo.synchronous.uri_parser import parse_uri |
41 | 41 |
|
@@ -148,89 +148,6 @@ def _create_user(authdb, user, pwd=None, roles=None, **kwargs): |
148 | 148 | return authdb.command(cmd) |
149 | 149 |
|
150 | 150 |
|
151 | | -class client_knobs: |
152 | | - def __init__( |
153 | | - self, |
154 | | - heartbeat_frequency=None, |
155 | | - min_heartbeat_interval=None, |
156 | | - kill_cursor_frequency=None, |
157 | | - events_queue_frequency=None, |
158 | | - ): |
159 | | - self.heartbeat_frequency = heartbeat_frequency |
160 | | - self.min_heartbeat_interval = min_heartbeat_interval |
161 | | - self.kill_cursor_frequency = kill_cursor_frequency |
162 | | - self.events_queue_frequency = events_queue_frequency |
163 | | - |
164 | | - self.old_heartbeat_frequency = None |
165 | | - self.old_min_heartbeat_interval = None |
166 | | - self.old_kill_cursor_frequency = None |
167 | | - self.old_events_queue_frequency = None |
168 | | - self._enabled = False |
169 | | - self._stack = None |
170 | | - |
171 | | - def enable(self): |
172 | | - self.old_heartbeat_frequency = common.HEARTBEAT_FREQUENCY |
173 | | - self.old_min_heartbeat_interval = common.MIN_HEARTBEAT_INTERVAL |
174 | | - self.old_kill_cursor_frequency = common.KILL_CURSOR_FREQUENCY |
175 | | - self.old_events_queue_frequency = common.EVENTS_QUEUE_FREQUENCY |
176 | | - |
177 | | - if self.heartbeat_frequency is not None: |
178 | | - common.HEARTBEAT_FREQUENCY = self.heartbeat_frequency |
179 | | - |
180 | | - if self.min_heartbeat_interval is not None: |
181 | | - common.MIN_HEARTBEAT_INTERVAL = self.min_heartbeat_interval |
182 | | - |
183 | | - if self.kill_cursor_frequency is not None: |
184 | | - common.KILL_CURSOR_FREQUENCY = self.kill_cursor_frequency |
185 | | - |
186 | | - if self.events_queue_frequency is not None: |
187 | | - common.EVENTS_QUEUE_FREQUENCY = self.events_queue_frequency |
188 | | - self._enabled = True |
189 | | - # Store the allocation traceback to catch non-disabled client_knobs. |
190 | | - self._stack = "".join(traceback.format_stack()) |
191 | | - |
192 | | - def __enter__(self): |
193 | | - self.enable() |
194 | | - |
195 | | - @no_type_check |
196 | | - def disable(self): |
197 | | - common.HEARTBEAT_FREQUENCY = self.old_heartbeat_frequency |
198 | | - common.MIN_HEARTBEAT_INTERVAL = self.old_min_heartbeat_interval |
199 | | - common.KILL_CURSOR_FREQUENCY = self.old_kill_cursor_frequency |
200 | | - common.EVENTS_QUEUE_FREQUENCY = self.old_events_queue_frequency |
201 | | - self._enabled = False |
202 | | - |
203 | | - def __exit__(self, exc_type, exc_val, exc_tb): |
204 | | - self.disable() |
205 | | - |
206 | | - def __call__(self, func): |
207 | | - def make_wrapper(f): |
208 | | - @wraps(f) |
209 | | - async def wrap(*args, **kwargs): |
210 | | - with self: |
211 | | - return await f(*args, **kwargs) |
212 | | - |
213 | | - return wrap |
214 | | - |
215 | | - return make_wrapper(func) |
216 | | - |
217 | | - def __del__(self): |
218 | | - if self._enabled: |
219 | | - msg = ( |
220 | | - "ERROR: client_knobs still enabled! HEARTBEAT_FREQUENCY={}, " |
221 | | - "MIN_HEARTBEAT_INTERVAL={}, KILL_CURSOR_FREQUENCY={}, " |
222 | | - "EVENTS_QUEUE_FREQUENCY={}, stack:\n{}".format( |
223 | | - common.HEARTBEAT_FREQUENCY, |
224 | | - common.MIN_HEARTBEAT_INTERVAL, |
225 | | - common.KILL_CURSOR_FREQUENCY, |
226 | | - common.EVENTS_QUEUE_FREQUENCY, |
227 | | - self._stack, |
228 | | - ) |
229 | | - ) |
230 | | - self.disable() |
231 | | - raise Exception(msg) |
232 | | - |
233 | | - |
234 | 151 | def _all_users(db): |
235 | 152 | return {u["user"] for u in db.command("usersInfo").get("users", [])} |
236 | 153 |
|
@@ -287,10 +204,6 @@ def print_thread_stacks(pid: int) -> None: |
287 | 204 | sys.stderr.write(res.stdout) |
288 | 205 |
|
289 | 206 |
|
290 | | -# Global knobs to speed up the test suite. |
291 | | -global_knobs = client_knobs(events_queue_frequency=0.05) |
292 | | - |
293 | | - |
294 | 207 | def _get_executors(topology): |
295 | 208 | executors = [] |
296 | 209 | for server in topology._servers.values(): |
|
0 commit comments