From a49a3103e298fcc4373856abe057dac09bc1df14 Mon Sep 17 00:00:00 2001 From: Surinder Kumar Date: Fri, 21 Jul 2017 09:46:30 +0100 Subject: [PATCH] Prevent the Werkzeug reloader from causing a "double start" at init time. --- web/pgAdmin4.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py index 1db495842..4a1855707 100644 --- a/web/pgAdmin4.py +++ b/web/pgAdmin4.py @@ -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: