"""Regression: watchdog must release its restart lock so a 2nd restart is not self-blocked."""
import importlib.util, sys, pathlib
p = pathlib.Path(__file__).with_name("watchdog_live.py")
spec = importlib.util.spec_from_file_location("wd", p); wd = importlib.util.module_from_spec(spec)
sys.modules["wd"] = wd; spec.loader.exec_module(wd)
import tempfile
wd.LOCK = pathlib.Path(tempfile.mkdtemp()) / "lock"
wd.emit = lambda *a, **k: None
assert wd.with_restart_lock()
wd.release_restart_lock()
assert wd.with_restart_lock(), "lock still held after release (self-block bug)"
wd.release_restart_lock()
print("OK test_watchdog_lock")
