mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-10-31 04:01:59 +01:00
ci: satisfy plugin branch quality gates
This commit is contained in:
1 parent
c0aeb89399
commit
9150264f49
6 files changed
+28
-34
No files matched your search
@@ -104,8 +104,8 @@ def main(argv: Optional[list[str]] = None) -> int:
|
||||
for sig in (signal.SIGINT, signal.SIGTERM):
|
||||
try:
|
||||
signal.signal(sig, _handle_signal)
|
||||
except Exception:
|
||||
pass
|
||||
except (OSError, ValueError) as exc:
|
||||
logger.debug("Could not register signal %s: %s", sig, exc)
|
||||
|
||||
logger.info("Plugin root: %s", plugins_root)
|
||||
logger.info("IPC socket: %s", socket_path)
|
||||
|
||||
+10
-5
@@ -93,9 +93,11 @@ class PluginIPCServer:
|
||||
self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
self._sock.bind(str(self.socket_path))
|
||||
try:
|
||||
os.chmod(self.socket_path, 0o660)
|
||||
except OSError:
|
||||
pass
|
||||
# Repeater and the manager may be separate processes in one service
|
||||
# group, so the local IPC socket is intentionally group-writable.
|
||||
os.chmod(self.socket_path, 0o660) # nosec B103
|
||||
except OSError as exc:
|
||||
logger.debug("Could not set IPC socket permissions: %s", exc)
|
||||
self._sock.listen(16)
|
||||
self._sock.settimeout(1.0)
|
||||
self._stop.clear()
|
||||
@@ -123,10 +125,13 @@ class PluginIPCServer:
|
||||
pass
|
||||
|
||||
def _serve_loop(self) -> None:
|
||||
assert self._sock is not None
|
||||
sock = self._sock
|
||||
if sock is None:
|
||||
logger.error("IPC serve loop started without a socket")
|
||||
return
|
||||
while not self._stop.is_set():
|
||||
try:
|
||||
conn, _ = self._sock.accept()
|
||||
conn, _ = sock.accept()
|
||||
except socket.timeout:
|
||||
continue
|
||||
except OSError:
|
||||
|
||||
@@ -571,8 +571,8 @@ class PluginRuntime:
|
||||
pass
|
||||
try:
|
||||
proc.wait(timeout=2)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc:
|
||||
logger.debug("Wait after killing %s failed: %s", plugin_id, exc)
|
||||
|
||||
with self._lock:
|
||||
self._cleanup_handle(plugin_id)
|
||||
@@ -593,12 +593,12 @@ class PluginRuntime:
|
||||
try:
|
||||
if handle.process.poll() is not None:
|
||||
self._exit_codes[plugin_id] = handle.process.returncode
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc:
|
||||
logger.debug("Could not record exit status for %s: %s", plugin_id, exc)
|
||||
try:
|
||||
handle.log_fp.close()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc:
|
||||
logger.debug("Could not close plugin log for %s: %s", plugin_id, exc)
|
||||
|
||||
@staticmethod
|
||||
def _rotate_log_if_needed(log_file: Path) -> None:
|
||||
|
||||
@@ -136,12 +136,9 @@ class PluginAPIEndpoints:
|
||||
else:
|
||||
delete_data = bool(raw)
|
||||
# JSON body optional
|
||||
try:
|
||||
body = self._json_body()
|
||||
if "delete_data" in body:
|
||||
delete_data = bool(body.get("delete_data"))
|
||||
except Exception:
|
||||
pass
|
||||
body = self._json_body()
|
||||
if "delete_data" in body:
|
||||
delete_data = bool(body.get("delete_data"))
|
||||
|
||||
def _uninstall():
|
||||
return self._client_or_raise().uninstall(plugin_id, delete_data=delete_data)
|
||||
|
||||
Reference in new issue
Block a user