Stop timer thread when stopping component

darcs-hash:20061130215532-86b55-c3093785c0b17528f6c667c4e877122583d2589e.gz
This commit is contained in:
David Rousselie
2006-11-30 22:55:32 +01:00
parent 0c94b77fdb
commit 04fee565a7
2 changed files with 7 additions and 3 deletions

View File

@@ -98,6 +98,7 @@ class JCLComponent(Component, object):
self.__logger = logging.getLogger("jcl.jabber.JCLComponent")
self.lang = Lang()
self.running = False
self.wait_event = threading.Event()
signal.signal(signal.SIGINT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
@@ -162,6 +163,7 @@ class JCLComponent(Component, object):
to_jid = _account.user_jid, \
stanza_type = "unavailable"))
self.db_disconnect()
self.wait_event.set()
timer_thread.join(JCLComponent.timeout)
self.disconnect()
self.__logger.debug("Exitting normally")
@@ -194,10 +196,12 @@ class JCLComponent(Component, object):
and self.stream.socket is not None):
self.handle_tick()
self.__logger.debug("Resetting alarm signal")
time.sleep(self.time_unit)
##time.sleep(self.time_unit)
self.wait_event.wait(self.time_unit)
except Exception, exception:
self.queue.put(exception)
raise
self.__logger.info("Timer thread terminated...")
def authenticated(self):
"""Override authenticated Component event handler