def get_downtime_intervals():
''' Returns dictionary of IntervalSets of downtime intervals per telescope resource. Caches the data and will
attempt to update the cache every 15 minutes, but fallback on using previous downtime list otherwise.
'''
downtime_intervals = caches['locmem'].get('downtime_intervals', [])
if not downtime_intervals:
# If the cache has expired, attempt to update the downtime intervals
try:
data = DowntimeDB._get_downtime_data()
downtime_intervals = DowntimeDB._order_downtime_by_resource(data)
caches['locmem'].set('downtime_intervals', downtime_intervals, 900)
caches['locmem'].set('downtime_intervals.no_expire', downtime_intervals)
except DowntimeDBException as e:
downtime_intervals = caches['locmem'].get('downtime_intervals.no_expire', [])
logger.warning(repr(e))
return downtime_intervals
评论列表
文章目录