stop poller threads on shutdown: cosmetics
cosmetics after gerrit Change-Id: I4d982f83e3fe5a8c8c821ac718e51b9a58de2a62
This commit is contained in:
parent
8d62375483
commit
e75b8b0b10
@ -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.
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user