Cleanup: IPC-Peer-Daten speichern, Ruff-Fixes

This commit is contained in:
HMS MediaEngine Agent
2026-09-11 00:50:55 +02:00
parent 9536e08748
commit 34dc112fa0
+10 -3
View File
@@ -65,6 +65,8 @@ class IpcServer:
self._heartbeat_task: asyncio.Task | None = None self._heartbeat_task: asyncio.Task | None = None
self._last_peer_heartbeat_ns: int = 0 self._last_peer_heartbeat_ns: int = 0
self.capabilities: dict = {} self.capabilities: dict = {}
self.peer_name: str = ""
self.peer_capabilities: dict = {}
self.name: str = "hms-renderer" self.name: str = "hms-renderer"
@property @property
@@ -97,10 +99,14 @@ class IpcServer:
self._writer = writer self._writer = writer
# auf hello warten # auf hello warten
hello_raw = await read_frame_async(reader) hello_raw = await read_frame_async(reader)
if hello_raw.get("type") != "command" or hello_raw.get("payload", {}).get("action") != "hello": action = hello_raw.get("payload", {}).get("action")
raise ProtocolError("EXPECTED_HELLO", f"got {hello_raw.get('type')}") if hello_raw.get("type") != "command" or action != "hello":
got = hello_raw.get("type")
raise ProtocolError("EXPECTED_HELLO", f"got {got}")
peer_caps = hello_raw.get("payload", {}).get("capabilities", {}) peer_caps = hello_raw.get("payload", {}).get("capabilities", {})
peer_name = hello_raw.get("payload", {}).get("name", "unknown") peer_name = hello_raw.get("payload", {}).get("name", "unknown")
self.peer_name = peer_name
self.peer_capabilities = peer_caps
if hello_raw.get("protocol_version") != PROTOCOL_VERSION: if hello_raw.get("protocol_version") != PROTOCOL_VERSION:
err = Envelope( err = Envelope(
type=MessageType.ERROR, type=MessageType.ERROR,
@@ -194,7 +200,8 @@ class IpcClient:
if raw.get("type") != "event" or raw.get("payload", {}).get("action") != "welcome": if raw.get("type") != "event" or raw.get("payload", {}).get("action") != "welcome":
raise ProtocolError("EXPECTED_WELCOME", f"got {raw.get('type')}") raise ProtocolError("EXPECTED_WELCOME", f"got {raw.get('type')}")
if raw.get("protocol_version") != PROTOCOL_VERSION: if raw.get("protocol_version") != PROTOCOL_VERSION:
raise ProtocolError("VERSION_MISMATCH", f"server sent version {raw.get('protocol_version')}") sent = raw.get("protocol_version")
raise ProtocolError("VERSION_MISMATCH", f"server sent version {sent}")
self._last_peer_heartbeat_ns = time.monotonic_ns() self._last_peer_heartbeat_ns = time.monotonic_ns()
self._heartbeat_task = asyncio.get_running_loop().create_task(self._send_heartbeats()) self._heartbeat_task = asyncio.get_running_loop().create_task(self._send_heartbeats())
return HandshakeInfo( return HandshakeInfo(