acsm-calibre-plugin/calibre-plugin/singleinstance_helper.py
Florian Bach f5e19f4391 Bunch of fixes
Fix #48
Fix SingleInstance in Calibre 4
Make plugin run in Calibre 3.48
2023-05-06 12:24:26 +02:00

18 lines
458 B
Python

from calibre.utils.lock import create_single_instance_mutex
class SingleInstance:
def __init__(self, name):
self.name = name
self.release_mutex = None
def __enter__(self):
self.release_mutex = create_single_instance_mutex(self.name)
return self.release_mutex is not None
def __exit__(self, *a):
if self.release_mutex is not None:
self.release_mutex()
self.release_mutex = None