Esempio n. 1
0
    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(),
        )
Esempio n. 2
0
def test_get_lock_timeout_default():
    assert utils.get_lock_timeout() == 1.8
Esempio n. 3
0
 def acquire(self, *args, **kwargs):
     return self.storage_lock.acquire(blocking=True,
                                      timeout=utils.get_lock_timeout())