-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix for tzinfo issues in JobQueue #1696
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
Fix for tzinfo issues in JobQueue #1696
Conversation
Bibo-Joshi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey. Thanks for the PR and sorry for the late reply.
I had a look at it and I think I changed my mind about the optional tzinfo argument:
- For
run_once, theJob.tzinfoisn't event accessed. We just run_put(job, when)and ifwhenis naive,to_float_timestampmakes sure to interpret it as UTC - For
run_repeating, only thefirstargument may need to be aware, so it holds the same as forrun_once - For
run_dailywe indeed need the time zone but that can be extracted fromtime
So the issue is really to make sure that Job will have UTC tzinfo, when an naive object is passed. So the only change we really need is the one you made on line 403:
self.tzinfo = tzinfo or _UTC
I know that I said otherwise before but seeing the changes I believe that the additional optional argument is more confusing than helpful.
Would you mind reverting the other changes? The simplification in line 278 is okay, though and the additional test is good as well :)
Please tell, if I'm missing something in my argumentation.
|
You're right in your argumentation - job = job_queue.run_repeating(self.job_run_once, 10)
job.tzinfo = dtm.timezone(dtm.timedelta(hours=3)) |
|
Okay, I see your point. However, I think it would be more appropriate then to move the addition of the
|
17186f8 to
3d42df3
Compare
1. Made sure that default tzinfo in JobQueue is UTC python-telegram-bot#1693. 2. Added test that checks that all methods by default set job.tzinfo as UTC.
4efb50f to
4a6df22
Compare
|
Agree, I reverted changes except actual fix for #1693 |
|
CI fail is unrelated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
825f5e8 to
4a6df22
Compare
|
Thank you for you contribution! |
Closes #1693
Changes:
tzinfoforrun_once,run_repeating.job.tzinfowill be set as UTC by default and notNone.job.tzinfoas UTC.First I've added
tzinfoargument torun_dailytoo but it's seems excessive. For example, to make sure that job will be ran every monday and tuesday on 14:00 in desired timezone you'd had to pass timezone twice - astime.tzinfoand astzinfo.And I think there is no need to use different timezones for
time.tzinfoandtzinfobecause result may be counterintuitive. So, I've removedtzinfofromrun_daily.