Skip to content

Commit

Permalink
add a global async scheduler (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsachs authored Sep 19, 2023
1 parent 4acda8c commit f7c0a75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/fides/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from fides.api.service.privacy_request.email_batch_service import (
initiate_scheduled_batch_email_send,
)
from fides.api.tasks.scheduled.scheduler import scheduler
from fides.api.tasks.scheduled.scheduler import async_scheduler, scheduler
from fides.api.ui import (
get_admin_index_as_response,
get_path_to_admin_ui_file,
Expand Down Expand Up @@ -262,6 +262,8 @@ async def setup_server() -> None:

if not scheduler.running:
scheduler.start()
if not async_scheduler.running:
async_scheduler.start()

initiate_scheduled_batch_email_send()

Expand Down
2 changes: 2 additions & 0 deletions src/fides/api/tasks/scheduled/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.schedulers.background import BackgroundScheduler

scheduler = BackgroundScheduler()
async_scheduler = AsyncIOScheduler()
5 changes: 4 additions & 1 deletion tests/ops/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fides.api.db.base import Base
from fides.api.db.session import get_db_engine, get_db_session
from fides.api.models.sql_models import DataCategory as DataCategoryDbModel
from fides.api.tasks.scheduled.scheduler import scheduler
from fides.api.tasks.scheduled.scheduler import async_scheduler, scheduler
from tests.conftest import create_citext_extension


Expand All @@ -37,6 +37,9 @@ def db(api_client, config):

if not scheduler.running:
scheduler.start()
if not async_scheduler.running:
async_scheduler.start()

SessionLocal = get_db_session(config, engine=engine)
the_session = SessionLocal()
# Setup above...
Expand Down

0 comments on commit f7c0a75

Please sign in to comment.