diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index 02c837e..fc76058 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -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 diff --git a/maloja/dev/profiler.py b/maloja/dev/profiler.py index 29bd231..7185431 100644 --- a/maloja/dev/profiler.py +++ b/maloja/dev/profiler.py @@ -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}") diff --git a/maloja/server.py b/maloja/server.py index e8f6288..a2ff5bc 100644 --- a/maloja/server.py +++ b/maloja/server.py @@ -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)