Merge pull request 'Log key cache expiry dates' (#156) from bugfix/key-queue-ttl-logs into develop
Reviewed-on: #156
This commit is contained in:
commit
c1c4bd1573
1 changed files with 6 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Key management utilities."""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
|
||||
from lacre.config import get_item
|
||||
|
||||
|
@ -9,6 +10,9 @@ from lacre.config import get_item
|
|||
_DEFAULT_TTL = 1
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def calculate_expiry_date(now: datetime) -> datetime:
|
||||
"""Calculate date-time of key queue item expiry.
|
||||
|
||||
|
@ -24,7 +28,9 @@ def _get_ttl():
|
|||
max_hours = get_item('database', 'max_queue_hours', _DEFAULT_TTL)
|
||||
try:
|
||||
ttl = int(max_hours)
|
||||
LOG.debug('Key configmration queue max item age: %d hours', ttl)
|
||||
return ttl
|
||||
except ValueError:
|
||||
# Not a valid integer, so we return the default.
|
||||
LOG.exception('Invalid max_queue_hours format: %s, using default (%d)', max_hours, _DEFAULT_TTL)
|
||||
return _DEFAULT_TTL
|
||||
|
|
Loading…
Reference in a new issue