[2017.7] Fix scheduled jobs if when parameter is a list

This commit is contained in:
Denys Havrysh 2017-07-04 11:09:45 +03:00
parent b95b165d0e
commit 905be493d4

View file

@ -1129,21 +1129,28 @@ class Schedule(object):
log.error('Invalid date string {0}. '
'Ignoring job {1}.'.format(i, job))
continue
when = int(time.mktime(when__.timetuple()))
if when >= now:
_when.append(when)
_when.append(int(time.mktime(when__.timetuple())))
if data['_splay']:
_when.append(data['_splay'])
# Sort the list of "whens" from earlier to later schedules
_when.sort()
for i in _when:
if i < now and len(_when) > 1:
# Remove all missed schedules except the latest one.
# We need it to detect if it was triggered previously.
_when.remove(i)
if _when:
# Grab the first element
# which is the next run time
# Grab the first element, which is the next run time or
# last scheduled time in the past.
when = _when[0]
if '_run' not in data:
data['_run'] = True
# Prevent run of jobs from the past
data['_run'] = bool(when >= now)
if not data['_next_fire_time']:
data['_next_fire_time'] = when