Closed sarimmehdi closed 2 years ago
I solved the problem by updating to Python 3.8. For those who still want to use Python 3.7, please change the above code to the following:
def profile_func(func):
def decorator_func(*args, **kwargs):
pr = cProfile.Profile()
pr.enable()
val = func(*args, **kwargs)
pr.disable()
s = io.StringIO()
sortby = SortKey.CUMULATIVE
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.dump_stats(filename=os.path.join(memex_utils.config.session, 'profiling.prof'))
return val
return decorator_func
Remember to from pstats import SecretKey
, or use pstats.SecretKey
I am using the following function as a decorator:
But I get the following error:
I am using Python 3.7