Skip to content

Commit

Permalink
Bugfix(worker): 🐛 模板成功失败数的修改独立至任务执行之外
Browse files Browse the repository at this point in the history
Fix #511
  • Loading branch information
a76yyyy committed Mar 9, 2024
1 parent c600f8b commit 4bdf9e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ async def do(self, task):
mtime=time.time(),
next=next,
sql_session=sql_session)
await self.db.tpl.incr_success(tpl['id'], sql_session=sql_session)

t = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
title = f"QD定时任务 {tpl['sitename']}-{task['note']} 成功"
Expand Down Expand Up @@ -305,11 +304,17 @@ async def do(self, task):
mtime=time.time(),
next=next,
sql_session=sql_session)
await self.db.tpl.incr_failed(tpl['id'], sql_session=sql_session)

logger_worker.error('taskid:%d tplid:%d failed! %.4fs \r\n%s', task['id'], task['tplid'], time.perf_counter(
) - start, str(e).replace('\\r\\n', '\r\n'))

async with self.db.transaction() as sql_session:
if tpl and tpl.get('id'):
if is_success:
await self.db.tpl.incr_success(tpl['id'], sql_session=sql_session)
else:
await self.db.tpl.incr_failed(tpl['id'], sql_session=sql_session)

if should_push:
try:
pushtool = Pusher(self.db, sql_session=sql_session)
Expand Down

0 comments on commit 4bdf9e7

Please sign in to comment.