Hi,

/newbie here/

I’ve up and running a very very simple task scheduler but I think it’s not well 
designed :/

under models/scheduler.py I have:

"
from gluon.scheduler import Scheduler

def task_add(name, target):
    sum = 'hello ' + name + ' ' + target + '\n'
    with open('/tmp/tasks', 'w') as f:
        f.write(sum)

scheduler = Scheduler(db, dict(task_add=task_add))
“

and in controller:

“
def new():

    form = SQLFORM(db.scan)
 
    name = “”
    target = “"

    if form.process().accepts(request.vars, session):

        name = form.vars.name
        target = form.vars.target

        response.flash = ‘Great scan'

    elif form.errors:
        response.flash = 'Error, try again'

    scheduler.queue_task('task_add’,
        pargs=[],
        pvars={'name': name, 'target': target},
        start_time=request.now,     #datetime
        stop_time = None,           #datetime
        timeout = 60,               #seconds
        prevent_drift=False,
        period=60,                  #seconds
        immediate=False,
        repeats = 1)

    return dict(scans=scans, form=form)
“

This snippet is working but I think this “scheduler.queue_task(…)” should be 
processed inside “if form.process().accepts()”. But if I change the scheduler 
snipper into that code section, the task wont run and I don’t know why.

two: questions
1) what I am  doing wrong?
1.1) Maybe I should db.commit when the task is over. Should I code this under 
scheduler.py? 
2) where can I learn more about debugging?

Many many thanks in advance :)

Cheers,
-- 
Frank

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to