Closed rivques closed 2 years ago
My intention in the near future is to remove esp32spi_wsgiserver
entirely and recommend that people use generic server implementations that use adafruit_requests
, of which there are several. This makes the library smaller and allows us to write better server implementations that can be used in more circumstances. The PR to do that is #167, which is stalled for other reasons.
Your fix sounds perfectly reasonable for now, and we can get it in for posterity.
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
andadafruit_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 throughdebug=True
logs and the various modules ofadafruit_esp32spi
, it seems like the issue is thatWSGIServer.finish_response
is sending data toESP_SPIcontrol.socket_write
one byte at a time. This bypassessocket_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 ofesp32spi_wsgiserver
where Isocket_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: