From 7f3a69b7a575b3b80e45fc902457416359e0e837 Mon Sep 17 00:00:00 2001 From: Mike Lee <96452814+MikeLeePoly@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:50:47 +1000 Subject: [PATCH] Fix memory leak when comparing requests (#6764) --- moto/core/responses_custom_registry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moto/core/responses_custom_registry.py b/moto/core/responses_custom_registry.py index f21a8bda4..b4642e852 100644 --- a/moto/core/responses_custom_registry.py +++ b/moto/core/responses_custom_registry.py @@ -26,9 +26,11 @@ class CustomRegistry(responses.registries.FirstMatchRegistry): self._registered.clear() def find(self, request: Any) -> Tuple[Optional[responses.BaseResponse], List[str]]: - all_possibles = responses._default_mock._registry.registered # We don't have to search through all possible methods - only the ones registered for this particular method - all_possibles.extend(self._registered[request.method]) + all_possibles = ( + responses._default_mock._registry.registered + + self._registered[request.method] + ) found = [] match_failed_reasons = [] for response in all_possibles: