How to use the locket.__init__.LockError function in locket

To help you get started, we’ve selected a few locket examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mwilliamson / locket.py / locket / __init__.py View on Github external
def _acquire_non_blocking(acquire, timeout, retry_period, path):
    if retry_period is None:
        retry_period = 0.05
    
    start_time = time.time()
    while True:
        success = acquire()
        if success:
            return
        elif (timeout is not None and
                time.time() - start_time > timeout):
            raise LockError("Couldn't lock {0}".format(path))
        else:
            time.sleep(retry_period)

locket

File-based locks for Python on Linux and Windows

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis