question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

timezone issue for scheduler

See original GitHub issue

sample code from apscheduler docs:

from pytz import utc
....
scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)

it works for ubuntu, but after I change OS to amazonlinux, does not work error message:

ERROR:apscheduler.jobstores.default:Unable to restore job "xxxx_job" -- removing it
Traceback (most recent call last):
  File "/usr/local/lib64/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 141, in _get_jobs
    jobs.append(self._reconstitute_job(row.job_state))
  File "/usr/local/lib64/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 125, in _reconstitute_job
    job_state = pickle.loads(job_state)
  File "/usr/local/lib/python2.7/site-packages/pytz/__init__.py", line 283, in _p
    return unpickler(*args)
  File "/usr/local/lib/python2.7/site-packages/pytz/tzinfo.py", line 539, in unpickler
    tz = pytz.timezone(zone)
  File "/usr/local/lib/python2.7/site-packages/pytz/__init__.py", line 177, in timezone
    raise UnknownTimeZoneError(zone)
UnknownTimeZoneError: 'local'

then I add a file /etc/timezone with content ‘Etc/UTC’, it works

when add a scheduled job, should it use timezone I passed in code otherwise read from /etc/timezone ? looks like it always get it from system config

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
qli-aacommented, May 31, 2018

pass timezone=utc to BackgroundScheduler like this:

from pytz import utc
scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)
  1. amazonlinux should be /etc/localtime, like centos/redhat instead of /etc/timezone, but tzlocal think it was not centos-like OS (because /etc/localtime exists but not a symlink), then return local timezone
0reactions
agronholmcommented, Jun 30, 2019

As for the first observed problem, it happened while restoring an existing job. The timezone you set for the scheduler does not affect jobs added before that. So, not a bug. As for the second, report that to the tzlocal issue tracker.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding the timezone when scheduling a meeting in ...
Users encountered the following issues when scheduling a RingCentral Meeting session from the RingCentral app: The timezone is different from ...
Read more >
Weekday use different Timezone · Issue #226 - GitHub
I have instances launched in us-east-2 region would like to use the aws-instance-scheduler stack launched in ap-southeast-2. I created a period
Read more >
Letting users choose timezone for scheduling system
How to design when users are from different timezones? Store datetime in UTC in your database. After users signup, when they login to...
Read more >
Job Scheduler Time Zone Issue | Support Center
Job Scheduled to run in BST Time zone is not running at the correct BST time. Job Scheduled to Run at 12.30 AM...
Read more >
Scheduled Task/Timezone Bug in all RTM Windows 10 ...
The workaround here, is to set the timezone to manual time, in a timezone that is a whole number offset, and then adjust...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found