stop poller threads on shutdown: cosmetics

cosmetics after gerrit

Change-Id: I4d982f83e3fe5a8c8c821ac718e51b9a58de2a62
This commit is contained in:
zolliker 2025-03-19 15:33:25 +01:00
parent 8d62375483
commit e75b8b0b10
2 changed files with 7 additions and 8 deletions

View File

@ -642,13 +642,12 @@ class Module(HasAccessibles):
"""
if self.__poller:
self.stopPollThread()
if timeout > 0:
self.__poller.join(timeout)
self.__poller.join(timeout)
if self.__poller.is_alive():
self.log.warning('can not stop poller')
def shutdownModule(self):
"""called when the sever shuts down
"""called when the server shuts down
any cleanup-work should be performed here, like closing threads and
saving data.

View File

@ -257,13 +257,13 @@ class SecNode:
def shutdown_modules(self):
"""Call 'shutdownModule' for all modules."""
# stop pollers
for name in self.modules:
self.modules[name].stopPollThread()
for mod in self.modules.values():
mod.stopPollThread()
# do not yet join here, as we want to wait in parallel
now = time.time()
deadline = now + 5
for name in self.modules:
self.modules[name].joinPollThread(now - deadline)
deadline = now + 0.5 # should be long enough for most read functions to finish
for mod in self.modules.values():
mod.joinPollThread(max(0, deadline - now))
now = time.time()
for name in self._getSortedModules():
self.modules[name].shutdownModule()