mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 22:24:16 +02:00
[appimage] database lock implemented
This commit is contained in:
18
bauh/gems/appimage/db.py
Normal file
18
bauh/gems/appimage/db.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
def acquire_lock(db_path: str):
|
||||
lock_path = db_path + '.lock'
|
||||
while True:
|
||||
if not os.path.exists(lock_path):
|
||||
open(lock_path, 'a').close()
|
||||
break
|
||||
else:
|
||||
time.sleep(0.0005)
|
||||
|
||||
|
||||
def release_lock(db_path: str):
|
||||
lock_path = db_path + '.lock'
|
||||
if os.path.exists(lock_path):
|
||||
os.remove(lock_path)
|
||||
Reference in New Issue
Block a user