openreplay/api/chalicelib/utils/dev.py
KRAIEM Taha Yassine 192d1231d4 Changes:
- fixed env-vars
- fixed EE signup
- changed EE DB structure
- changed FOS DB structure
- fixed announcements
- use minio for api
- use minio for sourcemaps-reader
- share env-vars with sourcemaps-reader
2021-05-09 02:23:26 +02:00

28 lines
1.2 KiB
Python

from functools import wraps
from time import time
import inspect
from chalicelib.utils import helper
def timed(f):
@wraps(f)
def wrapper(*args, **kwds):
if not helper.TRACK_TIME:
return f(*args, **kwds)
start = time()
result = f(*args, **kwds)
elapsed = time() - start
if inspect.stack()[1][3] == "_view_func":
print("DEBUG: %s: took %d s to finish" % (f.__name__, elapsed))
else:
call_stack = [i[3] for i in inspect.stack()[1:] if i[3] != "wrapper"]
call_stack = [c for c in call_stack if
c not in ['__init__', '__call__', 'finish_request', 'process_request_thread',
'handle_request', '_generic_handle', 'handle', '_bootstrap_inner', 'run',
'_bootstrap', '_main_rest_api_handler', '_user_handler',
'_get_view_function_response', 'wrapped_event', 'handle_one_request',
'_global_error_handler', 'openreplay_middleware']]
print("DEBUG: %s > %s took %d s to finish" % (" > ".join(call_stack), f.__name__, elapsed))
return result
return wrapper