Use thread pool scheduler
This commit is contained in:
parent
87f08d5c40
commit
c4dde7f7da
2 changed files with 4 additions and 8 deletions
|
@ -5,7 +5,7 @@ import sentry_sdk
|
||||||
from aiohttp.web import run_app as run_web_app
|
from aiohttp.web import run_app as run_web_app
|
||||||
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
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.settings import LOGGING_LEVEL, SENTRY_DSN
|
||||||
from actioner.web import get_server
|
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
|
# 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=run_web_app, args=(server,)).start()
|
||||||
Process(target=start_scheduler, args=(scheduler,)).start()
|
Process(target=scheduler.start).start()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||||
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||||
from apscheduler.triggers.interval import IntervalTrigger
|
from apscheduler.triggers.interval import IntervalTrigger
|
||||||
|
|
||||||
from .todoist_assigned_issues import todoist_assigned_issues
|
from .todoist_assigned_issues import todoist_assigned_issues
|
||||||
|
@ -8,7 +9,7 @@ from .todoist_repo_prs import todoist_repo_prs
|
||||||
|
|
||||||
|
|
||||||
def create_scheduler():
|
def create_scheduler():
|
||||||
scheduler = AsyncIOScheduler()
|
scheduler = BlockingScheduler()
|
||||||
scheduler.add_job(todoist_assigned_issues, "interval", minutes=15)
|
scheduler.add_job(todoist_assigned_issues, "interval", minutes=15)
|
||||||
scheduler.add_job(todoist_repo_prs, "interval", minutes=15)
|
scheduler.add_job(todoist_repo_prs, "interval", minutes=15)
|
||||||
|
|
||||||
|
@ -17,8 +18,3 @@ def create_scheduler():
|
||||||
scheduler.add_job(job.func)
|
scheduler.add_job(job.func)
|
||||||
|
|
||||||
return scheduler
|
return scheduler
|
||||||
|
|
||||||
|
|
||||||
def start_scheduler(scheduler):
|
|
||||||
scheduler.start()
|
|
||||||
asyncio.get_event_loop().run_forever()
|
|
||||||
|
|
Reference in a new issue