File size: 604 Bytes
5112867 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import traceback
from time import time
def ignore_exception(f):
def apply_func(*args, **kwargs):
try:
result = f(*args, **kwargs)
return result
except Exception:
if False:
print(f"Catched exception in {f}:")
traceback.print_exc()
return None
return apply_func
def time_it(f):
def apply_func(*args, **kwargs):
t_start = time()
result = f(*args, **kwargs)
t_end = time()
dur = round(t_end - t_start, ndigits=2)
return result, dur
return apply_func
|