stop scheduler when an application exits

This commit is contained in:
Romain Bignon 2010-09-28 11:29:32 +02:00
commit 0ce8b12c32
2 changed files with 8 additions and 0 deletions

View file

@ -74,6 +74,7 @@ class Scheduler(IScheduler):
for e in self.queue.itervalues():
e.cancel()
e.join()
self.queue = {}
def run(self):
try:
@ -88,6 +89,12 @@ class Scheduler(IScheduler):
def want_stop(self):
self.stop_event.set()
with self.mutex:
for t in self.queue.itervalues():
t.cancel()
# Contrary to _wait_to_stop(), don't call t.join
# because want_stop() have to be non-blocking.
self.queue = {}
def _repeated_cb(self, interval, function, args):
function(*args)

View file

@ -142,6 +142,7 @@ class BaseApplication(object):
self._parser.add_option('--shell-completion', action='store_true', help=optparse.SUPPRESS_HELP)
def deinit(self):
self.weboob.want_stop()
self.weboob.deinit()
def create_storage(self, path=None, klass=None, localonly=False):