From 5cc9ec620ff94287e7f622c927b5a928588e2a7a Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 20 Feb 2024 14:56:59 +0100 Subject: Adding PrintCallStack decorator to help in debug process. --- src/argaze/utils/UtilsFeatures.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/argaze/utils/UtilsFeatures.py b/src/argaze/utils/UtilsFeatures.py index da7565b..0a22aaf 100644 --- a/src/argaze/utils/UtilsFeatures.py +++ b/src/argaze/utils/UtilsFeatures.py @@ -10,6 +10,7 @@ __license__ = "BSD" from typing import Tuple import time import types +import traceback import numpy import cv2 @@ -261,4 +262,22 @@ class VideoWriter(): # Terminate the sub-process # Note: We don't have to terminate the sub-process (after process.wait(), the sub-process is supposed to be closed). - self.__process.terminate() \ No newline at end of file + self.__process.terminate() + +def PrintCallStack(method): + """Define a decorator to print call stack until the decorated method.""" + + def wrapper(self, *args, **kwargs): + """Wrap method to print call stack before its call. + + Parameters: + args: method arguments. + kwargs: extra arguments. + """ + print(f'Call stack until method \'{method.__name__}\':', ) + + traceback.print_stack() + + return method(self, *args, **kwargs) + + return wrapper \ No newline at end of file -- cgit v1.1