-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcronjob.py
32 lines (25 loc) · 855 Bytes
/
cronjob.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""This module runs app.py at a regular interval to
automatically register the next event in the queue."""
# Imports
import os
import sentry_sdk
from apscheduler.schedulers.blocking import BlockingScheduler # Scheduler
from headless_chrome import rsvp # Cron function
# Pylint config
# pylint: disable=abstract-class-instantiated
# Initialize Sentry error tracking, if SENTRY_DSN set
SENTRY_DSN = os.getenv('SENTRY_DSN')
if SENTRY_DSN:
sentry_sdk.init(
SENTRY_DSN,
traces_sample_rate=1.0
)
# Get cron interval, set default if not set
MIN_INTERVAL = os.getenv('MIN_INTERVAL', '3')
# Create an instance of scheduler and add function.
scheduler = BlockingScheduler()
scheduler.add_job(rsvp, "interval", minutes=int(MIN_INTERVAL))
# Start scheduler
scheduler.start()
# Pylint config
# pylint: enable=abstract-class-instantiated