mirror of
https://github.com/khoaliber/LetterFeed.git
synced 2026-03-02 21:19:13 +00:00
add job to scheduler instead of running immediately (#23)
* add job to scheduler instead of running immediately * fix test * Apply suggestions from code review * linting
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
@@ -42,8 +44,13 @@ def start_scheduler_with_interval():
|
||||
replace_existing=True,
|
||||
)
|
||||
if not scheduler.running:
|
||||
# Run the job immediately once
|
||||
job()
|
||||
scheduler.add_job(
|
||||
job,
|
||||
"date",
|
||||
run_date=datetime.now(),
|
||||
id="initial_email_check",
|
||||
replace_existing=True,
|
||||
)
|
||||
scheduler.start()
|
||||
logger.info("Scheduler started.")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user