From 93c3ea8d39117e46aa2fc3dada090f5807e1ab6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 29 Sep 2022 15:42:05 +0200 Subject: [PATCH] fix: Catch exception when Lacus is unreachable --- bin/async_capture.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/async_capture.py b/bin/async_capture.py index 8636c5e5..e6af116e 100755 --- a/bin/async_capture.py +++ b/bin/async_capture.py @@ -71,15 +71,20 @@ class AsyncCapture(AbstractManager): self.redis.delete(uuid) else: # Find a capture that is done - for uuid_b in self.redis.zrevrangebyscore('to_capture', 'Inf', '-Inf'): - uuid = uuid_b.decode() - if not uuid: - break - entries = self.lacus.get_capture(uuid) - if entries['status'] == CaptureStatusPy.DONE: - break - else: - # No captures are ready + try: + for uuid_b in self.redis.zrevrangebyscore('to_capture', 'Inf', '-Inf'): + uuid = uuid_b.decode() + if not uuid: + break + entries = self.lacus.get_capture(uuid) + if entries['status'] == CaptureStatusPy.DONE: + self.logger.info(f'Got the capture for {uuid} from Lacus') + break + else: + # No captures are ready + uuid = None + except Exception as e: + self.logger.critical(f'Error when getting captures from lacus, will retry later: {e}') uuid = None if uuid is None: @@ -167,6 +172,7 @@ class AsyncCapture(AbstractManager): lazy_cleanup.expire('queues', 600) lazy_cleanup.execute() self.unset_running() + self.logger.info(f'Done with {uuid}') async def _to_run_forever_async(self): capture = asyncio.create_task(self.process_capture_queue())