Open cskwrd opened 1 year ago
My use case is to interact with a home assistant installation via MQTT using the PyPortal with an interface dependent on asyncio. As such the invocation of .loop()
must be non-blocking. The workaround I implemented myself is to modify the check performed in the library's _sock_exact_recv
function, like so:
is_esp32spi_sock = self._sock.__module__.find('esp32spi')
if not is_esp32spi_sock and not self._backwards_compatible_sock:
I generally shy away from python so I have no idea how poor this fix is. If it's suitable I can put it in a PR.
As the title states this library uses the implementation meant for CPython/socket pools instead of the ESP32SPI implementation.
Steps to reporduce
Upload the following script, and install
adafruit_minimqtt
andadafruit_esp32spi
The above script is a modified version of examples/esp32spi/minimqtt_pub_sub_blocking_esp32spi.py. Modified to reduce dependence on secrets.py. Shortened
keep_alive
to exhibit bug sooner. Added non-zero timeout to.loop()
invocation to prevent infinite blocking loop (separate bug already mentioned in issues, #142).Actual Results
MMQTTException: Unable to receive 1 bytes within 5 seconds.
Expected Results
Checking for messages...
followed byDone...
repeatedly.Root cause
It appears as though this library makes an assumption that is the socket has a
recv_into
implementation, that the socket is not an ESP32SPI socket. As of approximately 18 months ago, this is no longer the case. Arecv_into
implementation was added toadafruit_esp32spi
. PR 151Library versions
boot_out.txt
Related
138
148