Shutdown Failure

On Python 3.10 (not officially supported by this project, yet) when the service is terminated, it seems to crash.

For example, on Arch Linux:

WARNING:root:Caught signal SIGTERM(15)
INFO:root:Main thread shutting down
INFO:root:Sending shutdown signal to "Plugin-0-lm_sensors" plugin
INFO:root:Shutting down "Plugin-0-lm_sensors" thread
WARNING:root:Caught signal SIGTERM(15)
Traceback (most recent call last):
  File "/root/mqtt4hass/mqtt4hass.py", line 441, in main
    idle()
  File "/root/mqtt4hass/mqtt4hass.py", line 414, in service_shutdown
    raise ServiceExit
__main__.ServiceExit
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/root/mqtt4hass/mqtt4hass.py", line 458, in <module>
    sys.exit(main())
  File "/root/mqtt4hass/mqtt4hass.py", line 446, in main
    ctrl.shutdown_plugins()
  File "/root/mqtt4hass/mqtt4hass.py", line 240, in shutdown_plugins
    if active_plugin.is_alive():
  File "/usr/lib/python3.10/threading.py", line 1162, in is_alive
    def is_alive(self):
  File "/root/mqtt4hass/mqtt4hass.py", line 414, in service_shutdown
    raise ServiceExit
__main__.ServiceExit

I recall seeing a similar trace on Windows. I can probably replicate if needed.

It is possible that with the recent change to running in a virtual environment (!32 (merged)), it is getting the shutdown signal twice now, once directly from systemd, and once again from Bash.

Edited by David G. Martin IV