Task timeout function sets alarm that triggers SIGALRM, which is then handled by throwing TaskTimeoutError. This mechanism should crash task that is running too long e.g. because of infinite loop or other conditon that caused the consumer to be hanged.
Unfortunately, TaskTimeoutError derives from Exception base class which means that it will be cached by any try..except clause that catches all Exceptions, which is pretty common pattern in Python, making timeout ineffective. This kind of situation happens in karton-config-extractor and malduck: https://github.com/CERT-Polska/malduck/blob/master/malduck/extractor/extractor.py#L447
This PR changes base class of TaskTimeoutError from Exception to BaseException (like GracefulShutdown).
BaseException is the common base class of all exceptions. One of its subclasses, Exception, is the base class of all the non-fatal exceptions. Exceptions which are not subclasses of Exception are not typically handled, because they are used to indicate that the program should terminate. They include SystemExit which is raised by sys.exit() and KeyboardInterrupt which is raised when a user wishes to interrupt the program.
from https://docs.python.org/3/tutorial/errors.html
Task timeout function sets alarm that triggers SIGALRM, which is then handled by throwing TaskTimeoutError. This mechanism should crash task that is running too long e.g. because of infinite loop or other conditon that caused the consumer to be hanged.
Unfortunately, TaskTimeoutError derives from Exception base class which means that it will be cached by any
try..except
clause that catches all Exceptions, which is pretty common pattern in Python, making timeout ineffective. This kind of situation happens in karton-config-extractor and malduck: https://github.com/CERT-Polska/malduck/blob/master/malduck/extractor/extractor.py#L447This PR changes base class of TaskTimeoutError from Exception to BaseException (like GracefulShutdown).