pytweezer.servers.process_cleanup module¶
Cross-platform cleanup for orphaned pytweezer server/device/logger processes.
Every managed process is spawned as ['python3', <script>, <name>] (see
bin/managed_panel.py/bin/process_tile_base.py). If the GUI that
launched them is killed rather than closed normally, these children can
outlive it and keep holding their ZMQ sockets, so the next
pytweezer-server/pytweezer-client launch fails to bind with “Address
already in use”. kill_stale_processes() finds and kills any such
leftover process by matching its command line against the script paths in
CONFIG["Servers"]/["Devices"]/["Loggers"].
This matches on process, not socket, so it also catches the pure-ZMQ- subscriber loggers that never bind a listening port at all.
xsub_xpub.py’s own _terminate_stale_instances does something similar
but POSIX-only (it scans /proc) and only for hub instances of the same
name about to start. This module is the general, cross-platform version meant
to be run on demand, from any PC role, against every managed category.