openlumi / lumimqtt

Service to control Xiaomi Gateway with MQTT
GNU General Public License v3.0
40 stars 14 forks source link

Respawn automatically if process died #35

Closed definitio closed 1 year ago

definitio commented 1 year ago

I have random connection related crashes:

Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]: ERROR:lumimqtt.lumimqtt:Unhandled exception during connecting
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]: Traceback (most recent call last):
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/lumimqtt/lumimqtt.py", line 504, in _connect_forever
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await connect_result.disconnect_reason
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/aio_mqtt/client.py", line 792, in _reading_task
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await self._read()
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/aio_mqtt/client.py", line 733, in _read
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     byte, = struct.unpack('!B', await self._reader.readexactly(1))
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/streams.py", line 708, in readexactly
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/streams.py", line 502, in _wait_for_data
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/selector_events.py", line 854, in _read_ready__data_received
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]: TimeoutError: [Errno 110] Operation timed out
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]: Traceback (most recent call last):
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/bin/lumimqtt", line 8, in <module>
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     sys.exit(main())
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/lumimqtt/__main__.py", line 102, in main
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     aio.run(amain())
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/lumimqtt/__main__.py", line 95, in amain
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await server.start()
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/lumimqtt/lumimqtt.py", line 99, in start
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     t.result()
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/lumimqtt/lumimqtt.py", line 377, in _periodic_publish
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await self._publish_light(light)
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/lumimqtt/lumimqtt.py", line 402, in _publish_light
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await self._client.publish(
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/aio_mqtt/client.py", line 301, in publish
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await self._wait((PacketType.PUBACK, packet_id))
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/aio_mqtt/client.py", line 367, in _wait
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     return await future
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/aio_mqtt/client.py", line 792, in _reading_task
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     await self._read()
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/site-packages/aio_mqtt/client.py", line 733, in _read
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:     byte, = struct.unpack('!B', await self._reader.readexactly(1))
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/streams.py", line 708, in readexactly
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/streams.py", line 502, in _wait_for_data
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]:   File "/usr/lib/python3.10/asyncio/selector_events.py", line 854, in _read_ready__data_received
Sun Mar 26 00:14:40 2023 daemon.err lumimqtt[2688]: TimeoutError: [Errno 110] Operation timed out

The easiest way to handle them is to enable auto respawning.