downtimedb.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:valhalla 作者: LCOGT 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号