Skip to content

LockNotOwnedError: Cannot release a lock that's no longer owned #223

Closed
@michaelbukachi

Description

@michaelbukachi

We started getting this error around a month ago. Not sure what changed, maybe something on Redis? Going through the source, in
redbeat/schedulers.py, I see we have this snippet:

def close(self):
        if self.lock:
            logger.debug('beat: Releasing Lock')
            self.lock.release()
            self.lock = None
        super(RedBeatScheduler, self).close()

Perhaps we can add an extra check i.e

def close(self):
        if self.lock:
            logger.debug('beat: Releasing Lock')
            # Add extra check
            if self.lock.owned() and self.lock.locked():
                self.lock.release()
            self.lock = None
        super(RedBeatScheduler, self).close()

Willing to do a quick PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions