Added support for users
This commit is contained in:
parent
646f0bb721
commit
88e2428a71
4 changed files with 220 additions and 2 deletions
41
libraries/check_task.py
Normal file
41
libraries/check_task.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from time import time
|
||||
from flask import flash
|
||||
|
||||
def check_task_status(flash_text, db, task_id):
|
||||
|
||||
first_time=time()
|
||||
|
||||
check_task=True
|
||||
|
||||
log={'error': 1, 'status': 1, 'message': ''}
|
||||
|
||||
while check_task:
|
||||
|
||||
with db.query('select * from logtask where task_id=%s order by id DESC limit 1', [task_id]) as cursor:
|
||||
|
||||
arr_log=cursor.fetchone()
|
||||
|
||||
if arr_log:
|
||||
|
||||
if arr_log['status']==1:
|
||||
|
||||
check_task=False
|
||||
|
||||
if not arr_log['error']:
|
||||
flash(flash_text)
|
||||
|
||||
log=arr_log
|
||||
|
||||
return log
|
||||
|
||||
|
||||
if time()-first_time>300:
|
||||
|
||||
log['message']='Error: task time out!, view task log!'
|
||||
log['error']=1
|
||||
|
||||
break
|
||||
|
||||
return log
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue