Lock scanner processing to a single runner

This commit is contained in:
Zoe Roux 2025-11-20 12:11:15 +01:00
parent 5bc6a06b91
commit 05f7fabb3c
No known key found for this signature in database

View File

@ -55,6 +55,7 @@ class RequestProcessor:
self._database: Connection = None # type: ignore self._database: Connection = None # type: ignore
self._client = client self._client = client
self._providers = providers self._providers = providers
self._processing = False
@tracer.start_as_current_span("listen_requests") @tracer.start_as_current_span("listen_requests")
async def listen(self, tg: TaskGroup): async def listen(self, tg: TaskGroup):
@ -85,14 +86,20 @@ class RequestProcessor:
raise raise
async def process_all(self): async def process_all(self):
found = True if self._processing:
while found: return
try: self._processing = True
found = await self.process_request() try:
except Exception as e: found = True
logger.error( while found:
"Failed to process one of the metadata request", exc_info=e 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): async def process_request(self):
cur = await self._database.fetchrow( cur = await self._database.fetchrow(