I encountered a problem while running the apscheduler library on Heroku hosting. I created my project a long time ago and everything worked fine, but 2 days ago I found that my code stopped working. It won't run anymore and I get an error:
2022-01-12T14:46:41.897611+00:00 app[worker.1]: /app/.heroku/python/lib/python3.9/site-packages/apscheduler/util.py:95: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
2022-01-12T14:46:41.897627+00:00 app[worker.1]: if obj.zone == 'local':
2022-01-12T14:46:41.897796+00:00 app[worker.1]: /app/.heroku/python/lib/python3.9/site-packages/apscheduler/util.py:166: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
2022-01-12T14:46:41.897797+00:00 app[worker.1]: return tz.localize(datetime_, is_dst=None)
The thing is that I didn't change anything in the code or in the hosting and everything works on my local machine without errors. I've tried solutions from the internet, like specifying a time zone or lowering the pytz version to 2.x. This does get rid of the error but the code still doesn't work on Heroku, it just stops in the same place but without errors. Here is part of my code:
# Create scheduler
scheduler = AsyncIOScheduler()
# Initialize news distribution
scheduler.add_job(services.news_distribution, 'interval', seconds=3600, next_run_time=datetime.now()) # Every hour
# Initialize daily text distribution
scheduler.add_job(services.daily_text_distribution, 'interval', seconds=900, next_run_time=datetime.fromtimestamp(my_round(time.time(), 900))) # Every 15 minutes & first run at closest multiple of 15 minutes
scheduler.start() # Start
Is there any solution and is the error related to my code or something happened in hosting? I will be glad to get your help.