Files
MediaFusion/utils/lock.py
T
2024-04-04 22:38:43 +05:30

18 lines
316 B
Python

import aiofiles
from aiofiles import os
async def acquire_lock():
try:
async with aiofiles.open(".lock", "x") as f:
return True
except FileExistsError:
return False
async def release_lock():
try:
await os.remove(".lock")
except FileNotFoundError:
pass