mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-19 10:58:06 +08:00
Save task now creates or updates
This way failed tasks that get requeued can have a changed status and result
This commit is contained in:
@@ -408,17 +408,19 @@ def save_task(task, broker):
|
||||
try:
|
||||
if task['success'] and 0 < Conf.SAVE_LIMIT <= Success.objects.count():
|
||||
Success.objects.last().delete()
|
||||
Task.objects.create(id=task['id'],
|
||||
name=task['name'],
|
||||
func=task['func'],
|
||||
hook=task.get('hook'),
|
||||
args=task['args'],
|
||||
kwargs=task['kwargs'],
|
||||
started=task['started'],
|
||||
stopped=task['stopped'],
|
||||
result=task['result'],
|
||||
group=task.get('group'),
|
||||
success=task['success'])
|
||||
Task.objects.update_or_create(id=task['id'],
|
||||
name=task['name'],
|
||||
defaults={
|
||||
'func': task['func'],
|
||||
'hook': task.get('hook'),
|
||||
'args': task['args'],
|
||||
'kwargs': task['kwargs'],
|
||||
'started': task['started'],
|
||||
'stopped': task['stopped'],
|
||||
'result': task['result'],
|
||||
'group': task.get('group'),
|
||||
'success': task['success']}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user