mirror of https://github.com/CIRCL/lookyloo
fix: Catch exception when Lacus is unreachable
parent
5be0014de7
commit
93c3ea8d39
|
@ -71,16 +71,21 @@ class AsyncCapture(AbstractManager):
|
||||||
self.redis.delete(uuid)
|
self.redis.delete(uuid)
|
||||||
else:
|
else:
|
||||||
# Find a capture that is done
|
# Find a capture that is done
|
||||||
|
try:
|
||||||
for uuid_b in self.redis.zrevrangebyscore('to_capture', 'Inf', '-Inf'):
|
for uuid_b in self.redis.zrevrangebyscore('to_capture', 'Inf', '-Inf'):
|
||||||
uuid = uuid_b.decode()
|
uuid = uuid_b.decode()
|
||||||
if not uuid:
|
if not uuid:
|
||||||
break
|
break
|
||||||
entries = self.lacus.get_capture(uuid)
|
entries = self.lacus.get_capture(uuid)
|
||||||
if entries['status'] == CaptureStatusPy.DONE:
|
if entries['status'] == CaptureStatusPy.DONE:
|
||||||
|
self.logger.info(f'Got the capture for {uuid} from Lacus')
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# No captures are ready
|
# No captures are ready
|
||||||
uuid = None
|
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:
|
if uuid is None:
|
||||||
self.unset_running()
|
self.unset_running()
|
||||||
|
@ -167,6 +172,7 @@ class AsyncCapture(AbstractManager):
|
||||||
lazy_cleanup.expire('queues', 600)
|
lazy_cleanup.expire('queues', 600)
|
||||||
lazy_cleanup.execute()
|
lazy_cleanup.execute()
|
||||||
self.unset_running()
|
self.unset_running()
|
||||||
|
self.logger.info(f'Done with {uuid}')
|
||||||
|
|
||||||
async def _to_run_forever_async(self):
|
async def _to_run_forever_async(self):
|
||||||
capture = asyncio.create_task(self.process_capture_queue())
|
capture = asyncio.create_task(self.process_capture_queue())
|
||||||
|
|
Loading…
Reference in New Issue