Description
Hi! I've been messing around with a Metro M4 Airlift Lite and hit an interesting snag when trying to serve a webpage using Adafruit's esp32spi_wsgiserver
and adafruit_wsgi.wsgi_app
. (Code is here for those interested.) When serving the webpage, I was getting only about 800 bits per second, slow enough to cause Chrome to have issues recognizing the format of the page as HTML because (I assume) the <!DOCTYPE html>
did not arrive quickly enough. After digging through debug=True
logs and the various modules of adafruit_esp32spi
, it seems like the issue is that WSGIServer.finish_response
is sending data to ESP_SPIcontrol.socket_write
one byte at a time. This bypasses socket_write
's built-in chunking and seems to cause a lot of extra overhead, possibly due to #108. To fix this I use a slightly modified version of esp32spi_wsgiserver
where I socket_write
the entire response at once if possible instead of looping over every char in the response and writing it individually. This increased data rate to something like 178 kbps. Anyways, my questions are:
- Am I missing something that would cause this to be a non-issue?
- Is this a known issue and if so, is there another workaround?
- Would this problem be fixed by ESP_SPIcontrol._wait_for_ready is eating lots of time polling the READY/BUSY pin #108 being resolved?
- Is my workaround a reasonable one, or does it have pitfalls I can't see? If so, should I put it in a PR to this repo?