4 ms·
I fail to see what other behaviour they could have. Picking a random port when you have been told to pick a specific port (even implicitly) makes no sense. Wha
by masklinn 5y ago
I fail to see what other behaviour they could have.
Picking a random port when you have been told to pick a specific port (even implicitly) makes no sense. What if I start flask telling it to use 8000 and it’s already taken by an other program I’m running (something I do semi-regularly as I run tests concurrently), just pick a random port unasked and notify no one about it?
- checkyoursudo 5y ago> notify no one about it But why this part? Python -m http.server tells me which port it is using or gives me "OSError: [Errno 48] Address already in use". In fact, I just tried python -m http.server $((10000 + RANDOM % 10000)) and it told me what port it started using.
- tsimionescu 5y agoGiven how much confusion the current behavior seems to have caused, the best course of action seems to have been a simple: "Listening on port $PORT. Warning: failed to bind localhost:5000. Start process with --port=$X to specify a different port" That would be much more helpful behavior and messaging than simply failing, especially since it seems people don't know that they can control the port, and start looking to disabling OS services rather than changing a port...
- the_mitsuhiko 5y agoIt might be something to consider, but there are definitely some negative consequences to silently starting on another port, particularly when using automation and tests. It's not fun to have flask silently start on another port and then an integration test hits a completely unrelated service that happens to occupy that port.
- checkyoursudo 5y agoTotally agree, but if you're running tests, presumably you are looking for errors in the first place, right? So it doesn't have to fail silently, does it? The testing tools failing for whatever reason seems important to know as well.