X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=lockfile.py;h=b6a832ee0e3a9c5eadb27cc3b1955538fb49c345;hb=ba223f821df1e9b8abbb6f6d23d5ba92c5a70b05;hp=34279ba8392c0e538ede3bfbc09b7af882657c16;hpb=b843703134a166013518c707fa5a77373f1bf0bf;p=python_utils.git diff --git a/lockfile.py b/lockfile.py index 34279ba..b6a832e 100644 --- a/lockfile.py +++ b/lockfile.py @@ -28,9 +28,15 @@ class LockFileContents: class LockFile(object): """A file locking mechanism that has context-manager support so you - can use it in a with statement. - """ + can use it in a with statement. e.g. + + with LockFile('./foo.lock'): + # do a bunch of stuff... if the process dies we have a signal + # handler to do cleanup. Other code (in this process or another) + # that tries to take the same lockfile will block. There is also + # some logic for detecting stale locks. + """ def __init__( self, lockfile_path: str,