From 881c4d6766e4423ca1a086efb0971c0c4aeafbb0 Mon Sep 17 00:00:00 2001 From: Harry Wang Date: Tue, 3 Sep 2024 13:05:19 +0800 Subject: [PATCH] Fixed that the exception param typing should be Exception --- taskiq/abc/middleware.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/taskiq/abc/middleware.py b/taskiq/abc/middleware.py index bc57ae2..d594cb8 100644 --- a/taskiq/abc/middleware.py +++ b/taskiq/abc/middleware.py @@ -131,7 +131,7 @@ def on_send_error( self, message: "TaskiqMessage", broker_message: "BrokerMessage", - exception: BaseException, + exception: Exception, ) -> "Union[Union[bool, None], Coroutine[Any, Any, Union[bool, None]]]": """ This function is called when exception is raised while sending a message. @@ -140,6 +140,9 @@ def on_send_error( Any exceptions occurred by broker's formatter will not trigger this. + SystemExit, KeyboardInterrupt as well as other BaseExceptions will not + be caught here as it would be essentially meaningless to catch them. + :param message: the sending TaskiqMessage (not BrokerMessage) :param broker_message: the sending BrokerMessage (not TaskiqMessage) :param exception: exception, not yet wrapped with SendTaskError