[scheduler] [fix] save scheduler_last_event at the start of scheduler
This commit is contained in:
parent
5561b6a594
commit
c4ab2bbc76
1 changed files with 8 additions and 7 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue