python API - detect shutdown
- djdelorie
- Away
- Senior Member
-
Less
More
- Posts: 68
- Thank you received: 10
04 Jul 2026 16:45 #347521
by djdelorie
python API - detect shutdown was created by djdelorie
I've seen a couple of "solutions" to this, but my question here is: what's the canonical way to detect that linuxcnc is shutting down and/or exiting, or isn't running, using the python linuxcnc.stat.poll() api ? I can start my python script in hal using loadusr, but there's no unloadusr, and I can't just run it at computer boot because linuxcnc.stat() just fails if linuxcnc isn't running yet. I tried using the parent PID but that isn't reliable (and prevents you from manually running the script in the background)
I've attached my script. I'd like to cleanly detect that linuxcnc has exited or the computer is shutting down, and send a final MQTT message to home assistant to update the status to "off".
I've attached my script. I'd like to cleanly detect that linuxcnc has exited or the computer is shutting down, and send a final MQTT message to home assistant to update the status to "off".
Please Log in or Create an account to join the conversation.
Time to create page: 0.170 seconds