tasks.py 文件源码

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

项目:zinc 作者: PressLabs 项目源码 文件源码
def update_ns_propagated(bind=True):
    redis_client = redis.from_url(settings.LOCK_SERVER_URL)

    # make this lock timeout big enough to cover updating about 1000 zones
    # ns_propagated flag and small enough to update the flag in an acceptable
    # time frame. 5 minutes sound good at the moment.

    lock = redis_client.lock('update_ns_propagated', timeout=300)
    if not lock.acquire(blocking=False):
        logger.info('Cannot aquire task lock. Probaly another task is running. Bailing out.')
        return
    try:
        models.Zone.update_ns_propagated(delay=getattr(settings, 'ZINC_NS_UPDATE_DELAY', 0.3))
    except Exception:
        logger.exception("Could not update ns_propagated flag")

    lock.release()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号