Last active
October 17, 2019 05:08
-
-
Save stickytruth/39c3fa2c88f141a0a26b to your computer and use it in GitHub Desktop.
Revisions
-
stickytruth revised this gist
Mar 11, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ """ Flask's reloader causes kernprof to fail. Without the reloader it appears to work. """ from flask import Flask, request @@ -20,6 +21,12 @@ def index(): if __name__ == '__main__': # Fails - "debug" enables the reloader # app.run('127.0.0.1', 5000, debug=True) # Works - "use_debugger" does not enable the reloader # app.run('127.0.0.1', 5000, use_debugger=False) # Fails # app.run('127.0.0.1', 5000, use_reloader=True) @@ -29,3 +36,4 @@ def index(): # Works with app.test_client() as c: c.get('/') -
stickytruth revised this gist
Mar 11, 2015 . 2 changed files with 18 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,5 +29,3 @@ def index(): # Works with app.test_client() as c: c.get('/') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ $ kernprof -l -v example.py Wrote profile results to example.py.lprof Timer unit: 1e-06 s Total time: 1.00117 s File: example.py Function: index at line 13 Line # Hits Time Per Hit % Time Line Contents ============================================================== 13 @app.route('/') 14 @profile 15 def index(): 16 1 1001072 1001072.0 100.0 time.sleep(1) 17 1 97 97.0 0.0 fn = request.environ.get('werkzeug.server.shutdown') 18 1 3 3.0 0.0 if fn: 19 fn() 20 1 2 2.0 0.0 return 'ok' -
stickytruth created this gist
Mar 11, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ """ Flask's reloader causes kernprof to fail. """ from flask import Flask, request import time app = Flask(__name__) app.testing = True @app.route('/') @profile def index(): time.sleep(1) fn = request.environ.get('werkzeug.server.shutdown') if fn: fn() return 'ok' if __name__ == '__main__': # Fails # app.run('127.0.0.1', 5000, use_reloader=True) # Works # app.run('127.0.0.1', 5000, use_reloader=False) # Works with app.test_client() as c: c.get('/') # kernprof -l -v example.py