Skip to content

Check if PidFile is locked without actually locking it #40

@tejasvi

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

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