def acquire_distributed_beat_lock(sender=None, **kwargs):
    """
    Attempt to acquire lock on startup

    Celery will squash any exceptions raised here. If one is raised
    scheduler.lock will be None while scheduler.lock_key is set
    """
    scheduler = sender.scheduler
    if not scheduler.lock_key:
        return

    logger.debug('beat: Acquiring lock...')
    redis_client = get_redis(scheduler.app)

    lock = redis_client.lock(
        scheduler.lock_key,
        timeout=scheduler.lock_timeout,
        sleep=scheduler.max_interval,
    )
    # overwrite redis-py's extend script
    # which will add additional timeout instead of extend to a new timeout
    lock.lua_extend = redis_client.register_script(LUA_EXTEND_TO_SCRIPT)
    lock.acquire()
    logger.info('beat: Acquired lock')
    scheduler.lock = lock

    Attempt to acquire lock on startup

    Celery will squash any exceptions raised here. If one is raised
    scheduler.lock will be None while scheduler.lock_key is set
    
redbeat/schedulers.py