Skip to content

Check if PidFile is locked without actually locking it #40

Description

@tejasvi

I am using PidFileError exception raised while acquiring the lock to check its acquired status. But it interferes with the other attempts to acquire the lock during the check period. Is there a way get the status directly?

def is_locked(filename):
    try:
        with PidFile(filename):
            # Parallel lock acquire attempts fail here
            return False
    except PidFileError:
        return True

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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