mirror of
https://github.com/Leseratte10/acsm-calibre-plugin
synced 2024-12-27 09:58:19 +01:00
f5e19f4391
Fix #48 Fix SingleInstance in Calibre 4 Make plugin run in Calibre 3.48
17 lines
458 B
Python
17 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
|
|
|