I'm developing a Flask app to host a REST API service. In order to distribute the code for testing on differing systems, I can't hard-code the port that the application runs on.
When running Flask 0.12.2 I am able to use the command app.run(port=0)
to get a usable port assigned by the OS. This works.
When I try the same command with Flask 1.0.2, I receive the message OSError: [Errno 98] Address already in use
.
Does anyone know why there is this discrepancy, and whether there's a workaround using Flask 1.0.2?
I'm aware that it's possible to get a socket assigned by the OS using Python's socket
module, but the ensuing race condition isn't acceptable for the testing environment.