stop scheduler when an application exits
This commit is contained in:
parent
6973611e2a
commit
0ce8b12c32
2 changed files with 8 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue