Hi,
I have a web application hosted on AWS EC2 with Apache2. I plan to use
web2py scheduler for some heavy tasks with user input files. Now I only use
some small tasks like "wc -c" to test the functions of scheduler. It seems
that the submitted tasks are always QUEUED and the status never changes.
After searching the google group, I added "db.commit()" right after
"scheduler.queue_task()", but it still cannot work.
I've already Installed the scheduler as a permanent daemon on Linux and
started "web2py-scheduler" using "sudo start web2py-scheduler".
Here is part of my codes in default.py:
def index():
response.flash = T("Welcome to web2py!")
form=SQLFORM(db.project,fields=['name',
'Genome',"File_type","InputFile"])
if request.vars.InputFile!=None and
request.vars.InputFile.filename.split(".")[-1]!=request.vars.File_type:
response.flash = 'The input file must match file type, please fill
again'
return dict(form=form)
if request.vars.InputFile!=None:
form.vars.processID="0"
if form.process().accepted:
response.flash = 'form accepted'
filepath = form.vars.InputFile
command = "wc -c
/home/www-data/web2py/applications/BamToVcf/uploads/"+filepath
p = scheduler.queue_task('run',[command])
db.commit()
row = db(db.project.InputFile==filepath).select().first()
row.update_record(processID = p.uuid)
redirect(URL("progress",args=[p.uuid]))
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = "please fill out the form"
return dict(form=form)
def progress():
processID = request.args(0)
project = db.project(db.project.processID==processID)
status=scheduler.task_status(processID,output=True)
start_time = utc_to_local(status.scheduler_task.start_time)
return dict(project=project,p=status,start_time=start_time)
def list():
rows = db(db.project.id>0).select()
return dict(rows=rows)
And the code in scheduler.py in Models folder:
from gluon.scheduler import Scheduler
import subprocess
from collections import OrderedDict
import os
def run(command):
p = subprocess.Popen(command,
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
startTime = time.time()
stdout, stderr = p.communicate()
endTime = time.time()
return (command, p.returncode, stdout, stderr, round(endTime -
startTime))
def demo2(a,b):
return a+b
scheduler = Scheduler(db,dict(run=run,demo2=demo2))
>From the database page ("~/%app/appadmin/index"), I can see the records of
tasks in db.scheduler_task table but no record in db.scheduler_worker and
db.scheduler_run table.
Could any one help me figure out the problem?
Thanks very much!
--
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.