Added "runserver_profile" management command.

This commit is contained in:
Sybren A. Stüvel 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
/pillar/pillar.egg-info/
/pillar/google_app.json
profile.stats

View File

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