diff --git a/weboob/core/scheduler.py b/weboob/core/scheduler.py index e3e8d2bc..32056ff2 100644 --- a/weboob/core/scheduler.py +++ b/weboob/core/scheduler.py @@ -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) diff --git a/weboob/tools/application/base.py b/weboob/tools/application/base.py index 205461c8..bc0583c9 100644 --- a/weboob/tools/application/base.py +++ b/weboob/tools/application/base.py @@ -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):