From f34ee1e6cdd1c8f00b9d369bbe521cb347a861fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Tue, 26 Nov 2024 17:29:24 +0100 Subject: [PATCH] Do not miss remaining tasks --- app/events/event_dispatcher.py | 6 +++--- cron.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/events/event_dispatcher.py b/app/events/event_dispatcher.py index 2cf29b7e..f34c6556 100644 --- a/app/events/event_dispatcher.py +++ b/app/events/event_dispatcher.py @@ -55,18 +55,18 @@ class EventDispatcher: if dispatcher is None: dispatcher = GlobalDispatcher.get_dispatcher() if config.EVENT_WEBHOOK_DISABLE: - LOG.i("Not sending events because webhook is disabled") + LOG.d("Not sending events because webhook is disabled") return if not config.EVENT_WEBHOOK and skip_if_webhook_missing: - LOG.i( + LOG.d( "Not sending events because webhook is not configured and allowed to be empty" ) return partner_user = EventDispatcher.__partner_user(user.id) if not partner_user: - LOG.i(f"Not sending events because there's no partner user for user {user}") + LOG.d(f"Not sending events because there's no partner user for user {user}") return event = event_pb2.Event( diff --git a/cron.py b/cron.py index d2f986e5..5772e119 100644 --- a/cron.py +++ b/cron.py @@ -1011,6 +1011,8 @@ async def _hibp_process_queue_check(api_key: str, queue: asyncio.Queue): try: alias_id = queue.get_nowait() except asyncio.QueueEmpty: + if len(alias_tasks) > 0: + await asyncio.gather(*alias_tasks, return_exceptions=True) return alias = Alias.get(alias_id) @@ -1021,8 +1023,6 @@ async def _hibp_process_queue_check(api_key: str, queue: asyncio.Queue): if len(alias_tasks) >= config.HIBP_CONCURRENT_TASKS: await asyncio.gather(*alias_tasks, return_exceptions=True) alias_tasks = [] - if len(alias_tasks) > 0: - await asyncio.gather(*alias_tasks, return_exceptions=True) async def _hibp_check_alias(alias: Alias, api_key: str, retries: int = 0):