From f4597f4fd46c8dc1b4baeeb71188703469ca1f5b Mon Sep 17 00:00:00 2001 From: fdev31 Date: Mon, 16 Oct 2023 00:19:25 +0200 Subject: [PATCH] add couple of logs & asserts Also invert the zombie process logic --- pyprland/command.py | 5 +++++ pyprland/plugins/scratchpads.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pyprland/command.py b/pyprland/command.py index 9196718..17ffd7c 100755 --- a/pyprland/command.py +++ b/pyprland/command.py @@ -73,6 +73,11 @@ class Pyprland: self.log.debug("%s.%s%s", plugin.name, full_name, params) try: await getattr(plugin, full_name)(*params) + except AssertionError as e: + self.log.error( + "Bug detected, please report on https://github.com/fdev31/pyprland/issues" + ) + self.log.exception(e) except Exception as e: # pylint: disable=W0718 self.log.warning( "%s::%s(%s) failed:", plugin.name, full_name, params diff --git a/pyprland/plugins/scratchpads.py b/pyprland/plugins/scratchpads.py index bf2a4d7..841a9a8 100644 --- a/pyprland/plugins/scratchpads.py +++ b/pyprland/plugins/scratchpads.py @@ -102,7 +102,7 @@ class Scratch: for line in f.readlines(): if line.startswith("State"): state = line.split()[1] - return state in "RSDTt" # not "Z (zombie)"or "X (dead)" + return state not in "ZX" # not "Z (zombie)"or "X (dead)" return False def reset(self, pid: int) -> None: @@ -199,7 +199,8 @@ class Extension(Plugin): # pylint: disable=missing-class-docstring self.procs[name] = proc pid = proc.pid self.scratches[name].reset(pid) - self.scratches_by_pid[proc.pid] = scratch + self.scratches_by_pid[pid] = scratch + self.log.info(f"scratch {scratch.uid} has pid {pid}") if old_pid and old_pid in self.scratches_by_pid: del self.scratches_by_pid[old_pid] @@ -375,9 +376,13 @@ class Extension(Plugin): # pylint: disable=missing-class-docstring del self.scratches_by_pid[item.pid] if item.address in self.scratches_by_address: del self.scratches_by_address[item.address] + self.log.info(f"starting {uid}") await self.start_scratch_command(uid) + self.log.info(f"{uid} started") + self.log.info("==> Wait for spawning") while uid in self._respawned_scratches: await asyncio.sleep(0.05) + self.log.info("<== spawned!") item.visible = True monitor = await get_focused_monitor_props() @@ -385,6 +390,8 @@ class Extension(Plugin): # pylint: disable=missing-class-docstring await self.updateScratchInfo(item) + assert item.address, "No address !" + addr = "address:0x" + item.address animation_type = item.conf.get("animation", "").lower()