##// END OF EJS Templates
Task #961: Actualizar status de modulos ABS con subproceso...
Task #961: Actualizar status de modulos ABS con subproceso git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@284 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r253:97011dacc8ab
r258:0e34c33380c6
Show More
tasks.py
38 lines | 730 B | text/x-python | PythonLexer
from __future__ import absolute_import
from celery import task
from datetime import timedelta, datetime
from .models import Experiment
@task
def task_start(id_exp):
exp = Experiment.objects.get(pk=id_exp)
return exp.start()
@task
def task_stop(id_exp):
exp = Experiment.objects.get(pk=id_exp)
return exp.stop()
#Task to get status
@task
def task_status(id_exp):
exp = Experiment.objects.get(pk=id_exp)
if exp.status==2:
run_every = timedelta(minutes=1)
now = datetime.utcnow()
date = now + run_every
task_status.apply_async((id_exp,), eta=date)
print "Monitoring..."
exp.get_status()
return exp.status
else:
return exp.status