def __init__(self): location = utils.get_lock_location() if location is None or location == '': raise ValueError( 'Redis server location must be set in the settings file.') self.redis_obj = Redis.from_url(location) self.storage_lock = self.redis_obj.lock( name=utils.get_lock_name(), timeout=utils.get_lock_time_to_live( ), # Time before lock is forcefully released. blocking_timeout=utils.get_lock_timeout(), )
def test_get_lock_timeout_default(): assert utils.get_lock_timeout() == 1.8
def acquire(self, *args, **kwargs): return self.storage_lock.acquire(blocking=True, timeout=utils.get_lock_timeout())