Simple scheduler issue

85 views
Skip to first unread message

Aydin

unread,
Dec 31, 2016, 1:39:36 PM12/31/16
to web...@googlegroups.com
I have a simple task to schedule:
def f():
    import time
    return()

from gluon.scheduler import Scheduler
Scheduler(db,dict(our_function=f))

When I run it with python web2py -K myapp, it gets stuck in "starting single-scheduler for "myapp"..." for long time and if I wait long enough it give "database is locked".
While waiting if I try to go to the app in the browser it won't work. Now, if I run the app without scheduler (removing -K myapp), and I go to my scheduler table I can see that the task had run successfully (while it was not accessible) 
Any one knows what's happening? and what the solution might be?

黄祥

unread,
Dec 31, 2016, 4:09:23 PM12/31/16
to web2py-users
perhaps, it related with database issue such as : sqlite
had you already tried another database like mysql or postgresql?

best regards,
stifan

Aydin

unread,
Jan 1, 2017, 11:14:21 AM1/1/17
to web2py-users
I have used the scheduler before without being worried about the database type. 
I tried to use mysql but it gave an error that it is not supported. I have mysql and pymysql installed and created a database "testdb" and used the manual format and got that error that it is not supported.

Niphlod

unread,
Jan 2, 2017, 11:04:44 AM1/2/17
to web2py-users
scheduler definitely works for mysql. 
what you experienced is perfectly fine. a scheduler process just sits there if there is nothing to do (i.e. no tasks to process).

Aydin

unread,
Jan 2, 2017, 11:12:39 AM1/2/17
to web2py-users
Would that break the connection to the server, because the website does not come up.

Aydin

unread,
Jan 2, 2017, 11:22:55 AM1/2/17
to web2py-users
I used the exact example shown by massimo (https://vimeo.com/27478796) and it gets stuck at (starting single-scheduler for myapp...) and the website does not come up saying browser cannot establish a connection). Running on ubuntu and debian.


On Monday, January 2, 2017 at 11:04:44 AM UTC-5, Niphlod wrote:

Aydin

unread,
Jan 2, 2017, 12:30:02 PM1/2/17
to web2py-users
I had defined a task to run every 30 seconds by the way. 


On Monday, January 2, 2017 at 11:04:44 AM UTC-5, Niphlod wrote:

Dave S

unread,
Jan 2, 2017, 1:38:42 PM1/2/17
to web2py-users


On Monday, January 2, 2017 at 8:22:55 AM UTC-8, Aydin wrote:
I used the exact example shown by massimo (https://vimeo.com/27478796) and it gets stuck at (starting single-scheduler for myapp...) and the website does not come up saying browser cannot establish a connection). Running on ubuntu and debian.

Can you show us your connection string (passwords obfuscated)?

/dps

Aydin

unread,
Jan 2, 2017, 1:58:25 PM1/2/17
to web2py-users
Sure, here are the databases I have tried to create:

# db2 = DAL('sqlite://scheduler_storage.sqlite')
# db2 = DAL('pymysql://root:pass@localhost/testdb2')
db2=DAL('mysql://root:pass@localhost/testdb2')

# db2 = DAL('MySQLdb://root:pass@localhost/testdb2')
# db2 = DAL('pymysql://root:pass@localhost/testdb1')

for MySQLdb and pymysql I get the error that they are not supported. mysql does not give that error but gets stuck in starting the task.
I even tried to import pymysql in web2py.py which did not help with the error of it being not supported.

Aydin

unread,
Jan 2, 2017, 2:28:37 PM1/2/17
to web2py-users
I had perfectly fine working app using scheduler in 2015, I tried to use that one but when trying to run the schedule (-K my app), the app does not run and web2py gets stuck in "starting single-scheduler...". This says to me something in terms of python and python tools version does not work well with web2py. I don't think there is anything wrong with the code I am using.

Niphlod

unread,
Jan 2, 2017, 6:04:57 PM1/2/17
to web2py-users
if you run a single process with 

python web2py.py -K appname 

ONLY the scheduler will be alive

the web-serving part needs to be started as usual, in addition to the previous process which just spins the scheduler process.

Aydin

unread,
Jan 2, 2017, 6:47:39 PM1/2/17
to web2py-users
I cann't believe I have spent 3 days trying every thing to find out what the hell is happening. Last time I used it, it was 2 years ago and I guess it was more intuitive to feel like python web2py.py -a pass -K myapp will run both the server and scheduler!!! Sorry everyone for the confusion.

Niphlod

unread,
Jan 4, 2017, 10:07:43 AM1/4/17
to web2py-users
you're probably referring to -X .

in any case, web2py.py -h is your best friend ;-)
Reply all
Reply to author
Forward
0 new messages