From 8e9e52105434e80bbcb276bcadcf7642f125fa6c Mon Sep 17 00:00:00 2001 From: schneefux Date: Mon, 1 Dec 2014 18:39:24 +0100 Subject: Run APScheduler in daemon mode and shut it down at exit --- client/notifier.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'client/notifier.py') diff --git a/client/notifier.py b/client/notifier.py index b081a66..941ae6b 100644 --- a/client/notifier.py +++ b/client/notifier.py @@ -1,5 +1,6 @@ # -*- coding: utf-8-*- import Queue +import atexit from modules import Gmail from apscheduler.scheduler import Scheduler import logging @@ -29,9 +30,10 @@ class Notifier(object): self._logger.warning('gmail_address or gmail_password not set ' + 'in profile, Gmail notifier will not be used') - sched = Scheduler() + sched = Scheduler(daemon=True) sched.start() sched.add_interval_job(self.gather, seconds=30) + atexit.register(lambda: sched.shutdown(wait=False)) def gather(self): [client.run() for client in self.notifiers] -- cgit v1.3.1