mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-23 01:34:36 +06:00
f5e19f4391
Fix #48 Fix SingleInstance in Calibre 4 Make plugin run in Calibre 3.48
18 lines
458 B
Python
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
|
|
|