A value of 0 is used to mean non-blocking or return immediately if no data is present, and value of None is used for blocking which would match the current behavior of esp32spi_socket.settimeout(0).
I'm not certain if we are stuck with this difference due to something in the underlying esp32 firmware or not. But if possible I think it would be best to try to match the cpython behavior here. So a value of 0 would be changed to be non-blocking, None would be supported to indicate blocking, and non-zero numbers would continue to behave the same.
As the code is now it means if you want non-blocking behavior you need to specify a really small timeout like 0.01 which isn't necessary with cpython.
In this library the socket.settimeout function mentions that it treats 0 as to mean block forever until data is received:
https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/blob/0adb75b898a133d929eb14baa2e54b7e9e23899c/adafruit_esp32spi/adafruit_esp32spi_socket.py#L146-L150
But in CPYthon the opposite is true: https://docs.python.org/3/library/socket.html#socket.socket.settimeout
A value of 0 is used to mean non-blocking or return immediately if no data is present, and value of None is used for blocking which would match the current behavior of esp32spi_socket.settimeout(0).
I'm not certain if we are stuck with this difference due to something in the underlying esp32 firmware or not. But if possible I think it would be best to try to match the cpython behavior here. So a value of 0 would be changed to be non-blocking,
None
would be supported to indicate blocking, and non-zero numbers would continue to behave the same.As the code is now it means if you want non-blocking behavior you need to specify a really small timeout like
0.01
which isn't necessary with cpython.