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