From bb448d2876d1065747b335fc98e191612135225a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 23 Aug 2024 02:00:25 +0200 Subject: [PATCH] chore: Update restrain_server function signature to specify return type --- server/src/uds/core/managers/servers_api/requester.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/uds/core/managers/servers_api/requester.py b/server/src/uds/core/managers/servers_api/requester.py index 1929bd45c..4ae5fe3ba 100644 --- a/server/src/uds/core/managers/servers_api/requester.py +++ b/server/src/uds/core/managers/servers_api/requester.py @@ -55,8 +55,8 @@ AUTH_TOKEN = 'X-TOKEN-AUTH' # If server is restrained, it will return False # If server is not restrained, it will execute the function and return it's result # If exception is raised, it will restrain the server and return False -def restrain_server(func: collections.abc.Callable[..., typing.Any]) -> collections.abc.Callable[..., typing.Any]: - def inner(self: 'ServerApiRequester', *args: typing.Any, **kwargs: typing.Any) -> typing.Any: +def restrain_server(func: collections.abc.Callable[..., bool]) -> collections.abc.Callable[..., bool]: + def inner(self: 'ServerApiRequester', *args: typing.Any, **kwargs: typing.Any) -> bool: if self.server.is_restrained(): return False @@ -64,7 +64,7 @@ def restrain_server(func: collections.abc.Callable[..., typing.Any]) -> collecti return func(self, *args, **kwargs) except Exception as e: restrained_until = sql_now() + datetime.timedelta(seconds=consts.system.FAILURE_TIMEOUT) - logger.exception('Error executing %s: %s. Server restrained until %s', func.__name__, e, restrained_until) + logger.error('Error executing %s: %s. Server restrained until %s', func.__name__, e, restrained_until) self.server.set_restrained_until( restrained_until ) # Block server for a while