add couple of logs & asserts

Also invert the zombie process logic
This commit is contained in:
fdev31 2023-10-16 00:19:25 +02:00
parent 4c8c570c7b
commit f4597f4fd4
2 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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()