Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File lock backend doesn't lock #220

Open
n6151h opened this issue Aug 30, 2022 · 0 comments
Open

File lock backend doesn't lock #220

n6151h opened this issue Aug 30, 2022 · 0 comments

Comments

@n6151h
Copy link

n6151h commented Aug 30, 2022

The backend.lock.file module has a bug in it that results in subsequent instances of CronJob classes being allowed to run even though ALLOW_PARALLELL_RUNS=False.

Take a look at line 20 (or 21 in 0.6.0, which is what pypi is providing):

    def lock(self):
        lock_name = self.get_lock_name()
        breakpoint()
        try:
            self.__lock_fd = open(lock_name, 'w+b', 1)
            locks.lock(self.__lock_fd, locks.LOCK_EX | locks.LOCK_NB)  <<< PROBLEM HERE
        except IOError:
            return False
        return True

In locks.lock(...) a BlockingIOError exception is thrown when a second (or more) instance tries to start, so it returns False, as it should. However, this return is effectively ignored (see <<< PROBLEM HERE) and the try/except block falls through to return True, which allows the instance to start regardless of the exclusion lock.

The problem line should simply return the result of locks.lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant