fix queue status
This commit is contained in:
parent
9c7552699f
commit
0f28a2b7d5
1 changed files with 8 additions and 5 deletions
|
@ -3,9 +3,11 @@
|
||||||
from __future__ import division, print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
from time import time
|
||||||
|
|
||||||
import celery.task.control
|
import celery.task.control
|
||||||
|
import kombu.five
|
||||||
|
|
||||||
|
|
||||||
from .models import File
|
from .models import File
|
||||||
|
|
||||||
|
@ -18,9 +20,10 @@ def parse_job(job):
|
||||||
'file': f.oshash
|
'file': f.oshash
|
||||||
}
|
}
|
||||||
if job['time_start']:
|
if job['time_start']:
|
||||||
|
start_time = datetime.fromtimestamp(time() - (kombu.five.monotonic() - job['time_start']))
|
||||||
r.update({
|
r.update({
|
||||||
'started': datetime.fromtimestamp(job['time_start']),
|
'started': start_time,
|
||||||
'running': time.time() - job['time_start'],
|
'running': (datetime.now() - start_time).total_seconds()
|
||||||
})
|
})
|
||||||
if f.encoding:
|
if f.encoding:
|
||||||
r['status'] = f.encoding_status()
|
r['status'] = f.encoding_status()
|
||||||
|
@ -33,10 +36,10 @@ def status():
|
||||||
}
|
}
|
||||||
encoding_jobs = ('archive.tasks.extract_stream', 'archive.tasks.process_stream')
|
encoding_jobs = ('archive.tasks.extract_stream', 'archive.tasks.process_stream')
|
||||||
c = celery.task.control.inspect()
|
c = celery.task.control.inspect()
|
||||||
for job in c.active(safe=True)['pandora-encoding']:
|
for job in c.active(safe=True).get('celery@pandora-encoding', []):
|
||||||
if job['name'] in encoding_jobs:
|
if job['name'] in encoding_jobs:
|
||||||
status['active'].append(parse_job(job))
|
status['active'].append(parse_job(job))
|
||||||
for job in c.reserved(safe=True)['pandora-encoding']:
|
for job in c.reserved(safe=True).get('celery@pandora-encoding', []):
|
||||||
if job['name'] in encoding_jobs:
|
if job['name'] in encoding_jobs:
|
||||||
status['queued'].append(parse_job(job))
|
status['queued'].append(parse_job(job))
|
||||||
return status
|
return status
|
||||||
|
|
Loading…
Reference in a new issue