[scheduler] [fix] save scheduler_last_event at the start of scheduler

This commit is contained in:
Anand Doshi 2013-05-02 10:01:18 +05:30
parent 5561b6a594
commit c4ab2bbc76

View file

@ -52,14 +52,19 @@ def execute():
out = []
# if first task of the day execute daily tasks
nowtime = webnotes.utils.now_datetime()
last = webnotes.conn.get_global('scheduler_last_event')
# set scheduler last event
webnotes.conn.begin()
webnotes.conn.set_global('scheduler_last_event', nowtime.strftime(format))
webnotes.conn.commit()
if last:
last = datetime.strptime(last, format)
if nowtime.day != last.day:
# if first task of the day execute daily tasks
out.append('daily:' + trigger('execute_daily'))
if nowtime.month != last.month:
@ -73,10 +78,6 @@ def execute():
out.append('all:' + trigger('execute_all'))
webnotes.conn.begin()
webnotes.conn.set_global('scheduler_last_event', nowtime.strftime(format))
webnotes.conn.commit()
return '\n'.join(out)
def trigger(method):
@ -90,7 +91,7 @@ def trigger(method):
webnotes.conn.commit()
return 'ok'
except Exception, e:
except Exception:
return log(method)
def log(method):