Apscheduler not working in Heroku

203 views
Skip to first unread message

Anika Duffus

unread,
Dec 30, 2020, 2:04:40 PM12/30/20
to APScheduler
I want to send text notifications using twilio and apscheduler. It works locally but the jobs are not being executed when deployed on heroku. Is there an extra step needed for heroku?

Alex Grönholm

unread,
Dec 30, 2020, 6:18:09 PM12/30/20
to apsch...@googlegroups.com

Are you using a clock worker for that? Heroku has a dedicated guide for apscheduler: https://devcenter.heroku.com/articles/clock-processes-python#apscheduler

Anika Duffus kirjoitti 30.12.2020 klo 21.04:
I want to send text notifications using twilio and apscheduler. It works locally but the jobs are not being executed when deployed on heroku. Is there an extra step needed for heroku? --
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/52fdacab-74fb-44e4-ac0f-565225196148n%40googlegroups.com.

Anika Duffus

unread,
Dec 30, 2020, 10:27:28 PM12/30/20
to APScheduler
I am using the date trigger. I am dynamically scheduling jobs so I do not think I can use the clock worker described. Here is the code I use:

if datetime.now(tz=tz) <= d-timedelta(days=2):
            trigger = DateTrigger(run_date=d-timedelta(days=2),
            timezone=tz)

            scheduler.add_job(send_sms_reminder, trigger=trigger,  
                id=str(slot_id), args=[slot_id], misfire_grace_time=60*2)

if datetime.now(tz=tz) <= d.replace(hour=7, minute=0):
            trigger = DateTrigger(run_date=d.replace(hour=7, minute=00),
            timezone=tz)

            scheduler.add_job(send_sms_reminder, trigger=trigger,
                id=str(slot.slot_id)+"*", args=[slot.slot_id], misfire_grace_time=60)

Alex Grönholm

unread,
Dec 31, 2020, 4:41:49 AM12/31/20
to apsch...@googlegroups.com

The problem is that other kinds of processes on Heroku do not run all the time so the scheduler will not work.

Anika Duffus

unread,
Dec 31, 2020, 10:29:14 AM12/31/20
to apsch...@googlegroups.com
So what should I do? That code is a part of a larger function. I can not put it in a separate clock file.

You received this message because you are subscribed to a topic in the Google Groups "APScheduler" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/apscheduler/B-EEzWOUNsQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to apscheduler...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apscheduler/f8b717ce-017b-c6ab-40e8-f5c8d53c8337%40nextday.fi.

Alex Grönholm

unread,
Jan 1, 2021, 8:03:20 AM1/1/21
to apsch...@googlegroups.com

I haven't used Heroku, but would it be possible to remotely control the clock process, via RPyC or similar? There's an example in the repository: https://github.com/agronholm/apscheduler/tree/3.x/examples/rpc

Reply all
Reply to author
Forward
0 new messages