Skip to content

Commit

Permalink
fix: Added exception handling when there is no key
Browse files Browse the repository at this point in the history
  • Loading branch information
fukusuket committed Aug 9, 2023
1 parent a47e32e commit 8ad865e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/caida_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ipaddress import ip_network
from typing import Dict, Any

from redis import Redis
from redis import Redis, exceptions

from ipasnhistory.default import get_socket_path, AbstractManager, get_config
from ipasnhistory.helpers import get_data_dir
Expand All @@ -33,7 +33,10 @@ def _to_run_forever(self):
self.load_all()

def already_loaded(self, address_family: str, date: str) -> bool:
return self.storagedb.sismember(f'{self.key_prefix}|{address_family}|dates', date)
try:
return self.storagedb.sismember(f'{self.key_prefix}|{address_family}|dates', date)
except exceptions.ResponseError:
return False

def update_last(self, address_family: str, date: str) -> None:
cur_last = self.storagedb.get(f'{self.key_prefix}|{address_family}|last')
Expand Down

0 comments on commit 8ad865e

Please sign in to comment.