From e5830181dd3677d1544bc598081c8d2bbe4c9f0b Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sun, 26 Jun 2022 13:05:08 +0000 Subject: [PATCH] ServerMode - dont bother resetting multiple times in parallel (#5264) --- moto/core/models.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/moto/core/models.py b/moto/core/models.py index 8b70ececa..c5f0602e1 100644 --- a/moto/core/models.py +++ b/moto/core/models.py @@ -333,16 +333,23 @@ MockAWS = BotocoreEventMockAWS class ServerModeMockAWS(BaseMockAWS): + + RESET_IN_PROGRESS = False + def __init__(self, *args, **kwargs): self.test_server_mode_endpoint = settings.test_server_mode_endpoint() super().__init__(*args, **kwargs) def reset(self): call_reset_api = os.environ.get("MOTO_CALL_RESET_API") - if not call_reset_api or call_reset_api.lower() != "false": - import requests + call_reset_api = not call_reset_api or call_reset_api.lower() != "false" + if call_reset_api: + if not ServerModeMockAWS.RESET_IN_PROGRESS: + ServerModeMockAWS.RESET_IN_PROGRESS = True + import requests - requests.post(f"{self.test_server_mode_endpoint}/moto-api/reset") + requests.post(f"{self.test_server_mode_endpoint}/moto-api/reset") + ServerModeMockAWS.RESET_IN_PROGRESS = False def enable_patching(self, reset=True): if self.__class__.nested_count == 1 and reset: