Open danchr opened 6 years ago
Excellent idea! Thanks for the contribution.
I am not familiar with Werkzeug's API to create servers but it looks like there is an option for threading here: https://github.com/pallets/werkzeug/blob/master/werkzeug/serving.py#L576. Is there a reason you're using a thread over the threaded mixin server?
Is there a reason you're using a thread over the threaded mixin server?
Well, yes; I wanted to use the serve_forever()
method, with blocks the thread. I don't think the threaded server helps with that, but rather allows the server to process multiple requests concurrently.
I tried switching my application to the Flask configuration system, and noticed that it didn't seem to affect the live server with these changes. I'll try to come up with a test to check whether that's a regression.
That was my thought - wanted to make sure I had the right idea. This is great. Let's get a test for that regression if you can manage it and then we'll merge
Running the server in a thread works quite well, and prevents any issues with communication between processes. Furthermore, it fixes stdio capturing to work as expected.
Tested by using something similar in my own test suite on Python 3.6, and by running
Flask-Testing
's own suite on Python 2.6, 2.7 and 3.6.