def check_task():
for key in RUNNING_TASK.keys():
#task_id???????
if str(key)[-1] != '_':
if RUNNING_TASK[key].ready():
# ????????
_end_task = Task.objects.get(id=key)
if RUNNING_TASK[key].failed():
_end_task.status = 'FAILURE'
else:
_end_task.status = 'SUCCESS'
attack_type = RUNNING_TASK[str(key)+'_']
task_id = key
result_2_db(task_id,attack_type,RUNNING_TASK[key])
_end_task.end_time = timezone.now()
_tmp_task = Result(task_id = _end_task.task_id,detail =RUNNING_TASK[key].get() )
_end_task.save()
_tmp_task.save()
transaction.commit()
del RUNNING_TASK[key]
#?????????????????RUNNING_TASK????????
'''
RUNNING_TASK_IN_DB = Task.objects.filter(Q(status = 'RUNNING'))
for _i in RUNNING_TASK_IN_DB:
if _i.id not in RUNNING_TASK.keys():
_i.status = 'FAILURE'
_i.except_message = 'Something error when check_task()'
#_i.end_time = timezone.now()
_i.save()
#RUNNING_TASK_IN_DB.save()
transaction.commit()
'''
#??????????????
评论列表
文章目录