On Sunday, April 3, 2016 at 1:03:11 AM UTC-7, narges Rezaei wrote:
>
> hi Pengfei Yu , is your code true? Is it working well?
> i want use it.
>


Careful about accessing the task table directly.  As Niphlod pointed out in 
another recent thread, these are "implementation dependent" and subject to 
change.  Using the queue_task() and task_status() calls should be the first 
choice.

Glad to see in your other thread that you've got your scheduler going.
<URL:https://groups.google.com/d/msg/web2py/sQL_0uu71gA/vlMmQGSJBAAJ>

/dps
 

>
> On Monday, September 29, 2014 at 6:07:53 PM UTC+3:30, Pengfei Yu wrote:
>>
>> 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.

Reply via email to