Use fasteners instead of pylockfile

This commit is contained in:
Rudra Saraswat 2023-05-09 12:06:00 +05:30
parent a91757d267
commit 5e4d2103a4

13
akshara
View file

@ -24,10 +24,9 @@ import yaml
import shutil import shutil
import argparse import argparse
import platform import platform
import fasteners
import subprocess import subprocess
from lockfile import LockFile
__version = '1.0.0' __version = '1.0.0'
with open('/etc/blend_release') as blend_release_file: with open('/etc/blend_release') as blend_release_file:
@ -383,13 +382,9 @@ try:
parser.parse_args(['--version']) parser.parse_args(['--version'])
elif command == handle_system_packages: elif command == handle_system_packages:
exec('touch', '/var/lib/.akshara-system-lock') exec('touch', '/var/lib/.akshara-system-lock')
system_lock = LockFile('/var/lib/.akshara-system-lock') system_lock = fasteners.InterProcessLock('/var/lib/.akshara-system-lock')
if not system_lock.is_locked(): with system_lock:
system_lock.acquire() command(args.command)
else:
error('system operation already in progress')
exit(1)
command(args.command)
else: else:
command() command()
except KeyboardInterrupt: except KeyboardInterrupt: