Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: crython for scheduled tasks #312

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions data-loading-service/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,46 @@
import utils.main_helper as main_helper
import threading
import time
from schedule import every, repeat, run_pending
import pandas as pd
# import schedule

@repeat(every(main_helper.set_interval_time()).seconds)
import crython
# import schedule
@crython.job(second='*/'+str(main_helper.set_interval_time())+'')
def gtfs_rt_scheduler():
try:
gtfs_rt_helper.update_gtfs_realtime_data()
except Exception as e:
print('Error updating GTFS-RT data: ' + str(e))

@repeat(every(1).day)
@crython.job(expr='@daily')
def go_pass_data_scheduler():
try:
gopass_helper.update_go_pass_data()
except Exception as e:
print('Error updating GTFS-RT data: ' + str(e))
print('Error updating Go Pass data ' + str(e))

@repeat(every(15).minutes)
@crython.job(expr='* */15 * * * * *')
def canceled_trips_update_scheduler():
try:
update_canceled_trips.run_update()
except Exception as e:
print('Error updating canceled trips: ' + str(e))

@repeat(every(7).days)
@crython.job(expr='@weekly')
def calendar_dates_update_scheduler():
try:
gtfs_static_helper.update_calendar_dates()
# gtfs_static_helper.update_gtfs_static_files()
except Exception as e:
print('Error updating canceled trips: ' + str(e))
print('Error updatin calendar dates: ' + str(e))

def initial_load():
gopass_helper.update_go_pass_data()
update_canceled_trips.run_update()
gtfs_rt_helper.update_gtfs_realtime_data()
# gtfs_rt_helper.update_gtfs_realtime_data()
gtfs_static_helper.update_calendar_dates()
# gtfs_static_helper.update_gtfs_static_files()
gopass_helper.update_go_pass_data()



if __name__ == '__main__':
initial_load()
while True:
run_pending()
crython.start()
crython.join()
3 changes: 2 additions & 1 deletion data-loading-service/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ google
protobuf==3.19.6
polyline
versiontag
gitpython
gitpython
crython
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ fastapi-redis-cache
fastapi-cache2[redis]
aioredis
versiontag
gitpython
gitpython
crython
Loading