Scheduler on Ubuntu Worker name

45 views
Skip to first unread message

Tushar Tuteja

unread,
Oct 16, 2013, 8:06:41 AM10/16/13
to web...@googlegroups.com
Hey I am using web2py on ubuntu.
I am trying to use the scheduler but there is not workers name that is coming .
and the task is always queued and it never runs.
I followed the video on Vimeo on scheduler.
it runs on mac but not on ubuntu.
apparently my app is hosted on a ubuntu server.

Niphlod

unread,
Oct 16, 2013, 8:23:30 AM10/16/13
to web...@googlegroups.com
a) what ubuntu ?
b) how do you start the scheduler ?

Tushar

unread,
Oct 16, 2013, 8:46:53 AM10/16/13
to web...@googlegroups.com
Ubuntu 12.04
i use the command
python web2py.py -K appName
--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Zs7NODudXSE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Niphlod

unread,
Oct 16, 2013, 9:04:20 AM10/16/13
to web...@googlegroups.com
ok. start it with 
python web2py.py -K appName -D 0 
that sets to DEBUG the logging level

Tushar

unread,
Oct 16, 2013, 2:29:12 PM10/16/13
to web...@googlegroups.com
I started with that only, but it is still now working.
SO I'll tell you what I did.
I made a file sched.py
# coding: utf8
def fun():
    import time
    print 'selecting mails'
    rows = db(db.queue.status=='pending').select()
    for row in rows:
        print 'sending mails'
        if mail.send(to=row.email,
            subject=row.subject,
            message=row.message_body):
            row.update_record(status='sent')
        else:
            row.update_record(status='failed')
        db.commit()
       
from gluon.scheduler import Scheduler
Scheduler(db,dict(func=fun))

then I edited the table scheduler_task
these are my values
scheduler_task.id scheduler_task.application_name scheduler_task.task_name scheduler_task.group_name scheduler_task.status scheduler_task.function_name scheduler_task.uuid scheduler_task.args scheduler_task.vars scheduler_task.enabled scheduler_task.start_time scheduler_task.next_run_time scheduler_task.stop_time scheduler_task.repeats scheduler_task.retry_failed scheduler_task.period scheduler_task.timeout scheduler_task.sync_output scheduler_task.times_run scheduler_task.times_failed scheduler_task.last_run_time scheduler_task.assigned_worker_name
2 b/appadmin mail main QUEUED func 85ebf3d6-35f8-4c6a-ac08-6477ee2af6b7 [] {} True 2013-10-16 17:26:38 2013-10-16 17:26:38 <NULL> 3 0 10 60 0 3 0 <NULL> tushar-VPCEB26FG#26573


and then I used this command

python web2py.py -K appName -D 0


it is still not sending mails and I get this in the console
"DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:looping...
INFO:web2py.scheduler.tushar-VPCEB26FG#26573:nothing to do
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:sleeping...
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:........recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:looping...
INFO:web2py.scheduler.tushar-VPCEB26FG#26573:nothing to do
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:sleeping...
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:........recording heartbeat (ACTIVE)
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:looping...
INFO:web2py.scheduler.tushar-VPCEB26FG#26573:nothing to do
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:sleeping...
DEBUG:web2py.scheduler.tushar-VPCEB26FG#26573:........recording heartbeat (ACTIVE)


thanks,

regards,

Tushar Tuteja
"

Niphlod

unread,
Oct 16, 2013, 2:52:21 PM10/16/13
to web...@googlegroups.com
the scheduler is running fine.
In the data you pasted here there's the reason why the scheduler isn't picking up any new task.
times_run is 3 and repeats is set to 3, so the task got executed 3 times already.

Sidenote: append a "return 1" to your function, so you'll get scheduler_run records holding more details about the executions, until you figure out the issues you're having on what to choose when you queue the task.

Also, please do

sched = Scheduler(db, dict(fun=func))

sched.queue_task('func', uuid='test_insert', repeats=3, period=10)

without any worker running, so you can see what is inserted into the scheduler_task table correctly.
Execute the sched.queue_task just one time only (if you put that in models, it will be executed at every request and that would be inefficient)


Tushar Tuteja

unread,
Oct 16, 2013, 2:55:34 PM10/16/13
to web...@googlegroups.com
thanks a ton,
I ll try this and what would be appropriate place to insert the file , so that it is not efficient.

thanks,

regards,

Tushar Tuteja


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Zs7NODudXSE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Tushar Tuteja
Undergraduate Student(Fourth Year)
Civil Engineering
IIT Delhi
"The question isn't who is going to let me; its who is going to stop me!" - Howard Roark

Niphlod

unread,
Oct 16, 2013, 3:15:23 PM10/16/13
to web...@googlegroups.com
the main point is not that is not inefficient by itself. It's just that you need to make sure you don't use that in a model because in web2py models are executed at **every** request, and you don't seem to want to queue a task for every request that comes in :-P

Tushar

unread,
Oct 16, 2013, 3:32:09 PM10/16/13
to web...@googlegroups.com
I got your point. It is that I made the whole project, its running except for sending mails I need to run the mail_queue file manually , I want it to run ever hour or so , so that the mails are being received.
so wanted to schedule the sending of mails once every hour and if the load increases , I would have reduced the time.
but I am unable to get the scheduler to work for this :p

Is there a way a parallel task is called as soon as a mail is inserted into the queue. it runs the file mail_queue but completes the request so that user doesn't have to wait.
because right now it takes 5 seconds if I use mail.send for the request to be completed. If I insert in the queue it complete the request in a minute.

thanks,

regards,

Tushar Tuteja

PS: web2py is really great and easy to learn and you guys are providing amazing support for this.
Me with my college mates at IIT Delhi (India) are actually promoting it and we have a small community among ourselves now :)

Tushar

unread,
Oct 16, 2013, 3:33:40 PM10/16/13
to web...@googlegroups.com
complete the request in a second if I insert in queue. and not a minute*


On Thursday 17 October 2013 12:45 AM, Niphlod wrote:

Niphlod

unread,
Oct 16, 2013, 3:41:55 PM10/16/13
to web...@googlegroups.com
the mail-sending usecase is one of the most clearer to show why a web app might need an "outside processor" to do the work, and keep the webapp snappy.
You can choose whatever method you like to schedule the task, all it needs is a record inserted into the scheduler_task table, with correct values.
Reply all
Reply to author
Forward
0 new messages