Added "runserver_profile" management command.

This commit is contained in:
2016-05-23 15:17:16 +02:00
parent 71db836d41
commit 75738efc0d
2 changed files with 11 additions and 2 deletions

1
.gitignore vendored
View File

@@ -15,3 +15,4 @@
/.coverage /.coverage
/pillar/pillar.egg-info/ /pillar/pillar.egg-info/
/pillar/google_app.json /pillar/google_app.json
profile.stats

View File

@@ -39,14 +39,15 @@ MONGO_HOST = os.environ.get('MONGO_HOST', 'localhost')
@manager.command @manager.command
def runserver(): def runserver(**options):
# Automatic creation of STORAGE_DIR path if it's missing # Automatic creation of STORAGE_DIR path if it's missing
if not os.path.exists(app.config['STORAGE_DIR']): if not os.path.exists(app.config['STORAGE_DIR']):
os.makedirs(app.config['STORAGE_DIR']) os.makedirs(app.config['STORAGE_DIR'])
app.run(host=app.config['HOST'], app.run(host=app.config['HOST'],
port=app.config['PORT'], port=app.config['PORT'],
debug=app.config['DEBUG']) debug=app.config['DEBUG'],
**options)
@manager.command @manager.command
@@ -60,6 +61,13 @@ def runserver_memlimit(limit_kb=1000000):
runserver() runserver()
@manager.command
def runserver_profile(pfile='profile.stats'):
import cProfile
cProfile.run('runserver(use_reloader=False)', pfile)
def post_item(entry, data): def post_item(entry, data):
return post_internal(entry, data) return post_internal(entry, data)