7

Any Heroku folks on here? It seems their system will not execute things from APScheduler labeled as cron. FYI: I'm using the free package. Using this example, the interval will run, the cron will not. Has anyone else run into this?

EDIT: Its been suggested that I specify UTC I am unsure how to do that using add_job. Any takers? Because I know this isn't currently right:

from apscheduler.schedulers.blocking import BlockingScheduler
from pytz import utc

sched = BlockingScheduler(timezone=utc)

def grabit():
    print "This job is run every weekday"

def tick():
    print "every 5 minutes"

sched.add_job(grabit, 'cron', day_of_week='mon-fri', hour=0, minute=13, id="get_things", replace_existing=True)
sched.add_job(tick, 'interval', minutes=5)
sched.start()
mishap_n
  • 578
  • 2
  • 10
  • 23

2 Answers2

19

You can pass the string like this:

sched = BlockingScheduler(timezone="Asia/Kolkata")

And find the string using thisL

from tzlocal import get_localzone
tz = get_localzone()
print(tz)

The object will contain the string

Dark Knight
  • 869
  • 1
  • 9
  • 18
0

Update to dark Knight's solution:

from tzlocal import get_localzone
tz = get_localzone()
print(tz)

Output:

Asia/Kolkata
rhoitjadhav
  • 691
  • 7
  • 16
  • Hi Manoj, welcome to stackoverflow. It's not clear to me how this answers the question being asked. Could you please elaborate? – demented hedgehog Jul 03 '20 at 23:55
  • 2
    Thank you demented hedgehog for the warm welcome. I came across this and thought of adding an update, I found to the dark Knight's solution. – Manoj Jadhav Jul 04 '20 at 16:24