feeph / libi2c-python

abstraction layer for the I²C bus (incl. simulation for testing)
GNU General Public License v3.0
1 stars 0 forks source link

fix: fix the retry-on-error logic #17

Closed feeph closed 3 months ago

feeph commented 3 months ago

The code did not perform a retry in case a spurious I/O error occured and failed from time to time. The logic to perform a retry was already there, but it did not handle this situation properly and returned to early.

Symptom:

>       return read_device_registers(i2c_bus, reads, max_tries, timeout_ms).pop()
E       IndexError: pop from empty list

.venv/lib/python3.11/site-packages/feeph/i2c/__init__.py:42: IndexError
------------------- Captured log call -------------------
WARNING  i2c:__init__.py:88 [feeph.i2c] Failed to read register 0x03 (1/3): [Errno 121] Remote I/O error