mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Fixes
This commit is contained in:
parent
40d5d0da78
commit
21d1c061bf
@ -810,8 +810,9 @@ def start_db():
|
|||||||
|
|
||||||
|
|
||||||
# create cached information
|
# create cached information
|
||||||
cached.update_medals()
|
# these are already run from the decorator!
|
||||||
cached.update_weekly()
|
#cached.update_medals()
|
||||||
|
#cached.update_weekly()
|
||||||
|
|
||||||
dbstatus['complete'] = True
|
dbstatus['complete'] = True
|
||||||
|
|
||||||
|
@ -8,25 +8,35 @@ from doreah.timing import Clock
|
|||||||
from ..pkg_global.conf import data_dir
|
from ..pkg_global.conf import data_dir
|
||||||
|
|
||||||
|
|
||||||
profiler = cProfile.Profile()
|
|
||||||
|
|
||||||
FULL_PROFILE = False
|
FULL_PROFILE = False
|
||||||
|
SINGLE_CALLS = False
|
||||||
|
# only save the last single call instead of adding up all calls
|
||||||
|
# of that function for more representative performance result
|
||||||
|
|
||||||
|
if SINGLE_CALLS:
|
||||||
|
profiler = cProfile.Profile()
|
||||||
|
|
||||||
def profile(func):
|
def profile(func):
|
||||||
def newfunc(*args,**kwargs):
|
def newfunc(*args,**kwargs):
|
||||||
|
|
||||||
if FULL_PROFILE:
|
|
||||||
benchmarkfolder = data_dir['logs']("benchmarks")
|
|
||||||
os.makedirs(benchmarkfolder,exist_ok=True)
|
|
||||||
|
|
||||||
clock = Clock()
|
clock = Clock()
|
||||||
clock.start()
|
clock.start()
|
||||||
|
|
||||||
if FULL_PROFILE:
|
if FULL_PROFILE:
|
||||||
profiler.enable()
|
benchmarkfolder = data_dir['logs']("benchmarks")
|
||||||
|
os.makedirs(benchmarkfolder,exist_ok=True)
|
||||||
|
if not SINGLE_CALLS:
|
||||||
|
localprofiler = cProfile.Profile()
|
||||||
|
else:
|
||||||
|
localprofiler = profiler
|
||||||
|
localprofiler.enable()
|
||||||
|
|
||||||
result = func(*args,**kwargs)
|
result = func(*args,**kwargs)
|
||||||
|
|
||||||
if FULL_PROFILE:
|
if FULL_PROFILE:
|
||||||
profiler.disable()
|
localprofiler.disable()
|
||||||
|
|
||||||
seconds = clock.stop()
|
seconds = clock.stop()
|
||||||
realfunc = func
|
realfunc = func
|
||||||
@ -36,7 +46,7 @@ def profile(func):
|
|||||||
if FULL_PROFILE:
|
if FULL_PROFILE:
|
||||||
targetfilename = os.path.join(benchmarkfolder,f"{realfunc.__name__}.stats")
|
targetfilename = os.path.join(benchmarkfolder,f"{realfunc.__name__}.stats")
|
||||||
try:
|
try:
|
||||||
pstats.Stats(profiler).dump_stats(targetfilename)
|
pstats.Stats(localprofiler).dump_stats(targetfilename)
|
||||||
log(f"Saved benchmark as {targetfilename}")
|
log(f"Saved benchmark as {targetfilename}")
|
||||||
except Exception:
|
except Exception:
|
||||||
log(f"Failed to save benchmark as {targetfilename}")
|
log(f"Failed to save benchmark as {targetfilename}")
|
||||||
|
@ -123,8 +123,8 @@ def dynamic_image():
|
|||||||
|
|
||||||
if result['type'] == 'noimage' and result['value'] == 'wait':
|
if result['type'] == 'noimage' and result['value'] == 'wait':
|
||||||
# still being worked on
|
# still being worked on
|
||||||
response.status = 503
|
response.status = 202
|
||||||
response.set_header('Retry-After',5)
|
response.set_header('Retry-After',15)
|
||||||
return
|
return
|
||||||
if result['type'] in ('url','localurl'):
|
if result['type'] in ('url','localurl'):
|
||||||
redirect(result['value'],307)
|
redirect(result['value'],307)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user