Hi, I am trying to run tasks in the future based on a time the user
specifies but as soon as the task is queued it is executed, what am I doing
wrong?
I am using web2py Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
This is my model.db (part of it)
db = DAL('sqlite://recomendadorexpertos.db')
db.define_table('topicos',
Field('curso', 'reference cursos'),
Field('nombre', 'string', required=True, length=512),
Field('palabras_clave', 'text', readable=False,
required=True, length=2048),
Field('fecha_inicio_identificacion', 'date', required=True,
comment=T('Indica la fecha desde la cual se empezará a buscar expertos.')),
Field('fecha_fin_identificacion', 'date', required=True,
comment=T('Indica la fehca en la cual se publicarán las recomendaciónes de
expertos.')),
Field('fecha_fin_publicacion', 'date', comment=T('Indica la
fecha hasta cuando se publicaran las recomendaciones de expertos
(opcional)')),
Field('timestamp_get_tweets_etiquetado', 'datetime',
readable=False, writable=False), #Para mostrar al usuario desde cuando se
estan descargando tweets para etiquetado.
Field('link_descarga_tweets_etiquetado', 'string',
readable=False, writable=False, length=2048),
Field('upload_archivo_etiquetado', 'upload', length=524288,
uploadfolder='/var/www/web2py/applications/RecomendadorExpertos/archivos_etiquetados/',
autodelete=True, comment=T('Primero inicie el proceso de descarga de tweets
para este topico, descargue el archivo para etiquetado, etiquetelo y subalo
aqui.'), label=T('Subir archivo etiquetado'), readable=False), #Cambiar el
nombre del archivo que suba a [nombre_topico].csv
Field('path_modelo', 'string', readable=False,
writable=False, length=2048), #Ruta del modelo entrenado
Field('topico_configurado_completamente', 'integer',
readable=True, writable=False, default=1,
represent=representTopicoConfigurado), #Sirve para mostrar un check alado
del archivo subido una vez terminado de generarse el modelo, para que el
profesor sepa que ya esta todo bien.
Field('id_scheduler_task_descarga_tweets', 'integer',
readable=False, writable=False),
Field('id_scheduler_task_identificacion_expertos',
'integer', readable=False, writable=False),
Field('id_scheduler_task_publicacion_expertos', 'integer',
readable=False, writable=False))
This is my Scheduler.py
def task_iniciar_descarga_tweets(row):
return 'descarga de tweets terminada'
def task_iniciar_identificacion_expertos(nombre_topico):
return 'identificacion de expertos terminada'
def task_publicar_expertos(nombre_topico):
return 'publicacion de expertos terminada'
dbScheduler = DAL('sqlite://scheduler.db')
scheduler = Scheduler(dbScheduler,
tasks={'task_iniciar_descarga_tweets':task_iniciar_descarga_tweets,
'task_iniciar_identificacion_expertos':task_iniciar_identificacion_expertos,
'task_publicar_expertos':task_publicar_expertos})
And this is my default.py controller (part of it)
@auth.requires_login()
def onCreateTopico(form):
row_task_iniciar_identificacion =
scheduler.queue_task('task_iniciar_identificacion_expertos',
pvars={'nombre_topico':form.vars.nombre},
start_time=datetime.datetime.combine(form.vars.fecha_inicio_identificacion,
datetime.time.min),
stop_time=datetime.datetime.combine(form.vars.fecha_fin_identificacion,
datetime.time.min), retry_failed=3)
row_task_iniciar_publicacion =
scheduler.queue_task('task_publicar_expertos',
pvars={'nombre_topico':form.vars.nombre},
start_time=datetime.datetime.combine(form.vars.fecha_fin_identificacion,
datetime.time.min), retry_failed=3)
db(db.topicos.id==form.vars.id).update(id_scheduler_task_identificacion_expertos=row_task_iniciar_identificacion.id,
id_scheduler_task_publicacion_expertos=row_task_iniciar_publicacion.id)
db.commit()
For instance, if I queue the task "task_iniciar_identificacion_expertos"
with a future start_time the worker executes this task inmediately, how can
I set the worker to execute this task in the future?
Thank you!
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.