skodaconnect / myskoda

Python library for interacting with MySkoda APIs.
MIT License
9 stars 22 forks source link

Task exception was never retrieved when experiencing reconnects #28

Closed WebSpider closed 2 months ago

WebSpider commented 2 months ago

When dealing with an unstable network environment, or unstable MQTT service, there are some unretrieved tasks causing errors, running 2cc3987 :

2024-09-23 16:11:48 mylaptop myskoda.mqtt[59293] INFO MQTT Connected.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] INFO Socket to MQTT broker closed.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] INFO Scheduling to reconnect MQTT.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] INFO Connection to MQTT broker lost, reason 16.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] INFO Scheduling to reconnect MQTT.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] INFO Connection to MQTT broker lost, reason 16.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] INFO Scheduling to reconnect MQTT.
2024-09-23 16:12:08 mylaptop myskoda.mqtt[59293] ERROR Failed to connect to MQTT.
2024-09-23 16:12:16 mylaptop myskoda.mqtt[59293] INFO MQTT Connected.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] INFO Socket to MQTT broker closed.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] INFO Scheduling to reconnect MQTT.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] INFO Connection to MQTT broker lost, reason 16.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] INFO Scheduling to reconnect MQTT.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] INFO Connection to MQTT broker lost, reason 16.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] INFO Scheduling to reconnect MQTT.
2024-09-23 16:12:43 mylaptop myskoda.mqtt[59293] ERROR Failed to connect to MQTT.
2024-09-23 16:12:49 mylaptop myskoda.mqtt[59293] INFO MQTT Connected.
2024-09-23 16:20:14 mylaptop asyncio[59293] ERROR Task exception was never retrieved
future: <Task finished name='Task-39' coro=<AsyncioPahoClient._loop_misc() done, defined at /home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/asyncio_paho/client.py:342> exception=FileNotFoundError(2, 'No such file or directory')>
Traceback (most recent call last):
  File "/home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/asyncio_paho/client.py", line 348, in _loop_misc
    self.reconnect()
  File "/home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/paho/mqtt/client.py", line 1088, in reconnect
    return self._send_connect(self._keepalive)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/paho/mqtt/client.py", line 2819, in _send_connect
    return self._packet_queue(command, packet, 0, 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/paho/mqtt/client.py", line 3018, in _packet_queue
    self._call_socket_register_write()
  File "/home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/paho/mqtt/client.py", line 2247, in _call_socket_register_write
    on_socket_register_write(
  File "/home/me/.virtualenvs/homeassistant-skoda/lib/python3.12/site-packages/asyncio_paho/client.py", line 318, in _on_socket_register_write_asyncio
    self._event_loop.add_writer(sock, client.loop_write)
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 367, in add_writer
    self._add_writer(fd, callback, *args)
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 325, in _add_writer
    self._selector.modify(fd, mask | selectors.EVENT_WRITE,
  File "/usr/lib/python3.12/selectors.py", line 389, in modify
    self._selector.modify(key.fd, selector_events)
FileNotFoundError: [Errno 2] No such file or directory
Prior99 commented 2 months ago

What is it trying to read from disk?

WebSpider commented 2 months ago

Its trying to read from a closed socket. Linux OS treats a socket as a file

WebSpider commented 2 months ago

Fixed in 0.6.1