From 525fa6e71c7677fb64997e79f2c38d0e3452e2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 20 Jan 2020 17:33:10 +0100 Subject: [PATCH] fixing actor on exit --- actor/src/udsactor/service.py | 9 ++++++++- actor/src/udsactor/windows/service.py | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/actor/src/udsactor/service.py b/actor/src/udsactor/service.py index 1432c2ff2..1cc73c451 100644 --- a/actor/src/udsactor/service.py +++ b/actor/src/udsactor/service.py @@ -148,7 +148,7 @@ class CommonService: # pylint: disable=too-many-instance-attributes self._certificate = self._api.ready(self._cfg.own_token, self._secret, srvInterface.ip, rest.LISTEN_PORT) self._ready = True except rest.RESTConnectionError as e: - logger.error('Error en ready: %s', e) + logger.error('Error en ready: %s -- %s', e, self._isAlive) if not logged: # Only log connection problems ONCE logged = True logger.error('Error connecting with UDS Broker') @@ -383,6 +383,13 @@ class CommonService: # pylint: disable=too-many-instance-attributes # **************************************** # Methods that CAN BE overriden by actors # **************************************** + def idle(self) -> None: + ''' + When needs to "pump" messages for example on Windows... + ''' + return + + def doWait(self, miliseconds: int) -> None: ''' Invoked to wait a bit diff --git a/actor/src/udsactor/windows/service.py b/actor/src/udsactor/windows/service.py index f8e219a24..2cc90f7ff 100644 --- a/actor/src/udsactor/windows/service.py +++ b/actor/src/udsactor/windows/service.py @@ -204,6 +204,9 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService): except Exception as e: logger.error('Exception removing user from Remote Desktop Users: {}'.format(e)) + def idle(self) -> None: + pythoncom.PumpWaitingMessages() # pylint: disable=no-member + def SvcDoRun(self) -> None: # pylint: disable=too-many-statements, too-many-branches ''' Main service loop @@ -221,6 +224,9 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService): win32event.WaitForSingleObject(self._hWaitStop, 5000) return # Stop daemon if initializes told to do so + # Initialization is done, set machine to ready for UDS, communicate urls, etc... + self.setReady() + # # ******************************** # # * Registers SENS subscriptions * # # ******************************** @@ -243,9 +249,6 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService): # logger.debug('Registered SENS') # logger.debug('Initialized, setting ready') - # Initialization is done, set machine to ready for UDS, communicate urls, etc... - self.setReady() - # ********************* # * Main Service loop * # *********************