From 49006f7886cb9f38a2b7cacd7b7c4ff32934c2b6 Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Mon, 24 May 2010 03:10:10 +0000 Subject: Terminate fam thread on shutdown When the bcfg2-server exits the fam thread is left running which hangs the process on exit. Resolves Ticket #709 git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5863 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index 4e3534c89..f659fec4a 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -60,6 +60,8 @@ class Core(Component): self.password = password self.encoding = encoding atexit.register(self.shutdown) + # Create an event to signal worker threads to shutdown + self.terminate = threading.Event() if '' in plugins: plugins.remove('') @@ -111,10 +113,11 @@ class Core(Component): def _file_monitor_thread(self): famfd = self.fam.fileno() - while True: + terminate = self.terminate + while not terminate.isSet(): try: if famfd: - select.select([famfd], [], []) + select.select([famfd], [], [], 15) else: while not self.fam.pending(): time.sleep(15) @@ -150,6 +153,7 @@ class Core(Component): (plugin), exc_info=1) def shutdown(self): + self.terminate.set() for plugin in self.plugins.values(): plugin.shutdown() -- cgit v1.2.3-1-g7c22