Closed DanielBaulig closed 2 years ago
This one's definitely arcane, and I checked through a few forum posts of people having the same issue with Chrome-based requests, but I think I have a solution. I changed the HTTP server implementation from a single-threaded BaseHTTPServer to a threaded ThreadingHTTPServer (the documentation even suggests this for clients that make multiple open requests) -
This is useful to handle web browsers pre-opening sockets, on which HTTPServer would wait indefinitely.
And changed the asyncio loop routine in the HTTP processor to create a new event loop for requests (as the "main" event loop doesn't exist in the separately created new threads) - everything seems to be running fine with those changes, but I want to test it in a few more situations before pushing a live commit.
OK, I've uploaded the latest commit - this changes the HTTP server implementation from the base HTTPServer to ThreadingHTTPServer, which allows multiple connections (I was testing it on Firefox and Chrome simultaneously on Windows, and on the both of them and Safari on Mac, with no HTTP hangups or application hangs on either), along with a few other changes to make this setup play nicely with how NeewerLite-Python/asyncio processes the commands.
I'm going to close this one out too @DanielBaulig as it's been a week - all is fine now in my testing using multiple browsers at the same time, but feel free to reopen if you come across an issue with this!
This is a little bit of an arcane bug, so exact steps to reproduce
Steps to reproduce:
NeewerLite-Python.py --cli --http
curl http://localhost:8080/NeewerLite-Python/list -v
curl http://localhost:8080/NeewerLite-Python/list -v
My (completely unfounded) guess is that it might be related to connection keep-alive or something like that in Chrome, but then again, I'm just making wild guesses here.