From 7a110edc2529111077351c31f4414849de5515d3 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Sun, 6 Feb 2022 15:11:01 +0800 Subject: Migrate AdminLog to sqlite --- jimbrella/lockfile.py | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 jimbrella/lockfile.py (limited to 'jimbrella/lockfile.py') diff --git a/jimbrella/lockfile.py b/jimbrella/lockfile.py deleted file mode 100644 index 987f0e3..0000000 --- a/jimbrella/lockfile.py +++ /dev/null @@ -1,33 +0,0 @@ -import os - - -class Lockfile: - """Prevent unwanted concurrency for file I/O. - - For a file named "", create or remove a lockfile named ".lock". - - When a process is modifying the file, call `lock(). When the modification - is done, call `unlock()`. - """ - - def __init__(self, filepath): - self.filepath = str(filepath) - self.lockpath = self.filepath + ".lock" - - def lock(self): - """Continue attempting to lock until locked.""" - locked = False - while not locked: - try: - f = open(self.lockpath, "x") - f.close() - locked = True - except FileExistsError: - continue - - def unlock(self): - """Remove lockfile.""" - try: - os.remove(self.lockpath) - except FileNotFoundError: - return -- cgit v1.2.3