From c4dde7f7daa98548aaff95c5e766def98050ba42 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 30 Aug 2019 19:33:32 +0100 Subject: [PATCH] Use thread pool scheduler --- actioner/main.py | 4 ++-- actioner/scheduler/__init__.py | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/actioner/main.py b/actioner/main.py index ff96437..694b54b 100644 --- a/actioner/main.py +++ b/actioner/main.py @@ -5,7 +5,7 @@ import sentry_sdk from aiohttp.web import run_app as run_web_app from sentry_sdk.integrations.aiohttp import AioHttpIntegration -from actioner.scheduler import create_scheduler, start_scheduler +from actioner.scheduler import create_scheduler from actioner.settings import LOGGING_LEVEL, SENTRY_DSN from actioner.web import get_server @@ -20,7 +20,7 @@ def main(): # HACK: APScheduler doesn't like running in an external event loop. https://github.com/agronholm/apscheduler/issues/360 Process(target=run_web_app, args=(server,)).start() - Process(target=start_scheduler, args=(scheduler,)).start() + Process(target=scheduler.start).start() if __name__ == "__main__": diff --git a/actioner/scheduler/__init__.py b/actioner/scheduler/__init__.py index 2f82a56..7703b95 100644 --- a/actioner/scheduler/__init__.py +++ b/actioner/scheduler/__init__.py @@ -1,6 +1,7 @@ import asyncio from apscheduler.schedulers.asyncio import AsyncIOScheduler +from apscheduler.schedulers.blocking import BlockingScheduler from apscheduler.triggers.interval import IntervalTrigger from .todoist_assigned_issues import todoist_assigned_issues @@ -8,7 +9,7 @@ from .todoist_repo_prs import todoist_repo_prs def create_scheduler(): - scheduler = AsyncIOScheduler() + scheduler = BlockingScheduler() scheduler.add_job(todoist_assigned_issues, "interval", minutes=15) scheduler.add_job(todoist_repo_prs, "interval", minutes=15) @@ -17,8 +18,3 @@ def create_scheduler(): scheduler.add_job(job.func) return scheduler - - -def start_scheduler(scheduler): - scheduler.start() - asyncio.get_event_loop().run_forever()