summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-12-01 18:39:24 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2014-12-01 18:39:24 +0100
commit8e9e52105434e80bbcb276bcadcf7642f125fa6c (patch)
tree5a5508818a8125a807bbab9a7ad7a2c101015327
parentae4833f1c3bdf77df62d9508798c983a452d509a (diff)
downloadjasper-client-8e9e52105434e80bbcb276bcadcf7642f125fa6c.tar.gz
jasper-client-8e9e52105434e80bbcb276bcadcf7642f125fa6c.zip
Run APScheduler in daemon mode and shut it down at exit
-rw-r--r--client/notifier.py4
1 files changed, 3 insertions, 1 deletions
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]