mirror of
https://github.com/Flowseal/tg-ws-proxy.git
synced 2026-05-22 23:41:44 +03:00
windows mutex-lock
This commit is contained in:
@@ -51,7 +51,7 @@ def ensure_dirs() -> None:
|
||||
_lock_file_path: Optional[Path] = None
|
||||
|
||||
|
||||
def _same_process(meta: dict, proc: psutil.Process, script_hint: str) -> bool:
|
||||
def _same_process(meta: dict, proc: psutil.Process) -> bool:
|
||||
try:
|
||||
lock_ct = float(meta.get("create_time", 0.0))
|
||||
if lock_ct > 0 and abs(lock_ct - proc.create_time()) > 1.0:
|
||||
@@ -63,7 +63,7 @@ def _same_process(meta: dict, proc: psutil.Process, script_hint: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def acquire_lock(script_hint: str = "") -> bool:
|
||||
def acquire_lock() -> bool:
|
||||
global _lock_file_path
|
||||
ensure_dirs()
|
||||
for f in list(APP_DIR.glob("*.lock")):
|
||||
@@ -84,7 +84,7 @@ def acquire_lock(script_hint: str = "") -> bool:
|
||||
pass
|
||||
is_running = False
|
||||
try:
|
||||
is_running = _same_process(meta, psutil.Process(pid), script_hint)
|
||||
is_running = _same_process(meta, psutil.Process(pid))
|
||||
except Exception:
|
||||
pass
|
||||
if is_running:
|
||||
|
||||
Reference in New Issue
Block a user