Scheduler is Not Running

40 views
Skip to first unread message

Suhas Jadhav

unread,
May 24, 2019, 3:05:31 AM5/24/19
to web...@googlegroups.com
Hi,

I have following code 

def fun1:
    do something
    returns locals()

I have below code in scheduler.py

def hcstar():
    LOAD('monitoring',' fun1')

from gluon.scheduler import Scheduler
    scheduler2 = Scheduler(db,tasks=dict(hcstar=hcstar,fun1=func2))

I have scheduled the task to run every 5 min.
I can see the task is changing the status as ASSIGNED-->QUEUED 
But I do not see the record being inserted into  db.scheduler_run 
 Also function  fun1  is not being called.

Can anybody help. 



--
Thanks,
Suhas

Dave S

unread,
May 24, 2019, 4:25:20 PM5/24/19
to web2py-users


On Friday, May 24, 2019 at 12:05:31 AM UTC-7, Suhas Jadhav wrote:
Hi,

I have following code 

def fun1:
    do something
    returns locals()

I have below code in scheduler.py

def hcstar():
    LOAD('monitoring',' fun1')

from gluon.scheduler import Scheduler
    scheduler2 = Scheduler(db,tasks=dict(hcstar=hcstar,fun1=func2))

From your defuns, neither hcstar nor fun1 appear to be task-like.  Tasks do not talk directly to a client ("the user"); instead they perform work on files or database entries or some such.  The scheduler will record their "stdout" (print statements, etc) and if the task returns a string or boolean.  If you're just trying to get familiar with setting up tasks, a function that does a print("Hello from taskA") and returns a True will work nicely.

The other part of the equation is that you have to have a thread or job running somewhere to launch the workers.  That's the job of the -K command line parameter.



I have scheduled the task to run every 5 min.
I can see the task is changing the status as ASSIGNED-->QUEUED 
But I do not see the record being inserted into  db.scheduler_run 
 Also function  fun1  is not being called.

Can anybody help. 



--
Thanks,
Suhas


Good luck!

Dave
/dps
 

Suhas Jadhav

unread,
May 24, 2019, 4:39:52 PM5/24/19
to web...@googlegroups.com
HI Dave,

How do I make hcstar  as a task. What is wrong in my code?

Thanks,
Suhas

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/33d86058-a557-49c6-9f7a-60cda9cdc030%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks,
Suhas

Dave S

unread,
May 24, 2019, 5:06:54 PM5/24/19
to web2py-users


On Friday, May 24, 2019 at 1:39:52 PM UTC-7, Suhas Jadhav wrote:
HI Dave,

How do I make hcstar  as a task. What is wrong in my code?

Thanks,
Suhas



The LOAD() helper is meant to be used in a view.  It isn't a useful tool in a task.  A task has no client, and no user interface.  Your controllers handle the client side, and use a task to handle something "behind the curtain", like a long-running computation, or generating reports based on recent database entries, or fetching remote resources.  The controller function can watch for task completion if the results need to be shown to the user.

What are you trying to do with a task?

/dps


What are you 
To unsubscribe from this group and stop receiving emails from it, send an email to web...@googlegroups.com.


--
Thanks,
Suhas
Reply all
Reply to author
Forward
0 new messages