From 05f7fabb3cbbee477ab7403f36585b8aaa0f48d5 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 20 Nov 2025 12:11:15 +0100 Subject: [PATCH] Lock scanner processing to a single runner --- scanner/scanner/requests.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/scanner/scanner/requests.py b/scanner/scanner/requests.py index fd6b8bb3..73db44ce 100644 --- a/scanner/scanner/requests.py +++ b/scanner/scanner/requests.py @@ -55,6 +55,7 @@ class RequestProcessor: self._database: Connection = None # type: ignore self._client = client self._providers = providers + self._processing = False @tracer.start_as_current_span("listen_requests") async def listen(self, tg: TaskGroup): @@ -85,14 +86,20 @@ class RequestProcessor: raise async def process_all(self): - found = True - while found: - try: - found = await self.process_request() - except Exception as e: - logger.error( - "Failed to process one of the metadata request", exc_info=e - ) + if self._processing: + return + self._processing = True + try: + found = True + while found: + try: + found = await self.process_request() + except Exception as e: + logger.error( + "Failed to process one of the metadata request", exc_info=e + ) + finally: + self._processing = False async def process_request(self): cur = await self._database.fetchrow(