ソースを参照

Add misfire grace and exit scheduler

JoostSijm 6 年 前
コミット
36631a8255
2 ファイル変更6 行追加1 行削除
  1. 5 1
      app/__init__.py
  2. 1 0
      app/__main__.py

+ 5 - 1
app/__init__.py

@@ -18,7 +18,11 @@ engine = create_engine(os.environ["DATABASE_URI"], client_encoding='utf8')
 Session = sessionmaker(bind=engine)
 
 # scheduler
-scheduler = BackgroundScheduler()
+scheduler = BackgroundScheduler(
+    daemon=True,
+    job_defaults={'misfire_grace_time': 5*60},
+)
+
 scheduler.start()
 
 # logging

+ 1 - 0
app/__main__.py

@@ -48,4 +48,5 @@ if __name__ == '__main__':
             time.sleep(100)
     except KeyboardInterrupt:
         LOGGER.info('Exiting application')
+        scheduler.shutdown()
         exit()