Prevent the Werkzeug reloader from causing a "double start" at init time.

This commit is contained in:
Surinder Kumar 2017-07-21 09:46:30 +01:00 committed by Dave Page
parent ede6765f6b
commit a49a3103e2

View File

@ -119,11 +119,19 @@ if __name__ == '__main__':
if IS_WIN:
os.environ['PYTHONHOME'] = sys.prefix
# Initialize Flask service only once
# If `WERKZEUG_RUN_MAIN` is None, i.e: app is initializing for first time
# so set `use_reloader` = False, thus reload won't call.
# Reference:
# https://github.com/pallets/werkzeug/issues/220#issuecomment-11176538
try:
app.run(
host=config.DEFAULT_SERVER,
port=server_port,
use_reloader=((not PGADMIN_RUNTIME) and app.debug),
use_reloader=(
(not PGADMIN_RUNTIME) and app.debug
and os.environ.get("WERKZEUG_RUN_MAIN") is not None
),
threaded=config.THREADED_MODE
)
except IOError: