-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional function for using apscheduler instead of schedule
- Loading branch information
Showing
2 changed files
with
26 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
import sys | ||
import threading | ||
import time | ||
|
||
import schedule | ||
import time | ||
from apscheduler.schedulers.blocking import BlockingScheduler | ||
|
||
from jobs.kostal_stats_job import main as k_m | ||
from jobs.kostal_aggregate_job import main as a_m | ||
from jobs.kostal_stats_job import main as k_m | ||
|
||
|
||
def main(): | ||
schedule.every(10).seconds.do(k_m) | ||
schedule.every(5).minutes.do(a_m) | ||
schedule.every(10).seconds.do(k_m) | ||
schedule.every(5).minutes.do(a_m) | ||
|
||
try: | ||
while True: | ||
schedule.run_pending() | ||
time.sleep(0.5) | ||
except KeyboardInterrupt: | ||
print("Shutting down from Keyboard Interrupt!") | ||
sys.exit() | ||
|
||
|
||
try: | ||
while True: | ||
schedule.run_pending() | ||
time.sleep(0.5) | ||
except KeyboardInterrupt: | ||
print("Shutting down from Keyboard Interrupt!") | ||
sys.exit() | ||
def main_apscheduler(): | ||
try: | ||
scheduler = BlockingScheduler() | ||
scheduler.add_job(k_m, "cron", second="0/10") | ||
scheduler.add_job(a_m, "cron", minute="0/5") | ||
scheduler.start() | ||
except KeyboardInterrupt: | ||
print("Shutting down from Keyboard Interrupt!") | ||
sys.exit() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
requests~=2.31.0 | ||
influxdb~=5.3.1 | ||
schedule~=1.2.1 | ||
pycryptodomex~=3.20.0 | ||
pycryptodomex~=3.20.0 | ||
APScheduler~=3.10.4 |