From 7a7595cf033b9198045a9daed79944d2992f4f49 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 5 Sep 2019 19:50:52 -0400 Subject: [PATCH] Fix flask run by not monkey patching for gevent in wsgi.py (#1101) * Fixes `flask run` debug server by not monkey patching in `wsgi.py` * Closes #1099 --- wsgi.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wsgi.py b/wsgi.py index b66234e2c..c9fb2d114 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,8 +1,14 @@ -from gevent import monkey -monkey.patch_all() +import os + +# Detect if we're running via `flask run` and don't monkey patch +if not os.getenv("FLASK_RUN_FROM_CLI"): + from gevent import monkey + + monkey.patch_all() + from CTFd import create_app app = create_app() -if __name__ == '__main__': +if __name__ == "__main__": app.run(debug=True, threaded=True, host="127.0.0.1", port=4000)