Skip to content

Commit

Permalink
Update time.py to solve the microsecond issues (celery#5199)
Browse files Browse the repository at this point in the history
When `relative` is set to True, the day, hour, minutes second will be round to the nearest one, however, the original program do not update the microsecond (reset it). As a result, the run-time offset on the microsecond will then be accumulated. 
For example, given the interval is 15s and relative is set to True
1.    2018-11-27T15:01:30.123236+08:00
2.    2018-11-27T15:01:45.372687+08:00
3.    2018-11-27T15:02:00.712601+08:00
4.    2018-11-27T15:02:15.987720+08:00
5.    2018-11-27T15:02:31.023670+08:00
  • Loading branch information
ckdanny authored and jeyrce committed Aug 25, 2021
1 parent d1e3084 commit d37035c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion celery/utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def remaining(start, ends_in, now=None, relative=False):
start = start.replace(tzinfo=now.tzinfo)
end_date = start + ends_in
if relative:
end_date = delta_resolution(end_date, ends_in)
end_date = delta_resolution(end_date, ends_in).replace(microsecond=0)
ret = end_date - now
if C_REMDEBUG: # pragma: no cover
print('rem: NOW:%r START:%r ENDS_IN:%r END_DATE:%s REM:%s' % (
Expand Down

0 comments on commit d37035c

Please sign in to comment.