Forums

web2py scheduler failing since Dec 1

Since Dec 1, I can no longer schedule tasks in my web2py scheduler; the task log is a LONG permutation of the following 3 lines:

ERROR:web2py.scheduler.giles-livetask1#7087:    error popping tasks
ERROR:web2py.scheduler.giles-livetask1#7087:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#7087:Error coordinating TICKER

interspersed every hour with something like

Failed to acquire lock, task must already be running
2017-12-06 08:04:12 -- Completed task, took 6.00 seconds, return code was 0.

I would try restarting it, but do not see how.

You can see what processes you have running under the scheduler by clicking the "Fetch process list" button at the bottom of the "Tasks" tab; there's a "kill" button next to each process.

The message saying "failed to acquire lock" is happening because you've written your scheduler code as a "long running task" as per https://help.pythonanywhere.com/pages/LongRunningTasks -- what it means is that your task was started, found an existing instance of itself already running, and so decided to immediately exit. If that's what you want to happen, it can be ignored.

Thanks for your reply; I have already tried restarting the scheduler.

The problem appears to be that I can no longer update the SQLite database that the scheduler relies on. If I use the database admin provided by web2py, I can request that records are deleted, and the request appears to have worked, but then the deleted records are all still there. If I try to add a record, I get the following error:

    Traceback (most recent call last):
  File "/Users/shunter/Dropbox/web2py_uki/applications/init/compiled/controllers.appadmin.select.py", line 249, in select
  File "/home/ukitms/web2py/gluon/packages/dal/pydal/objects.py", line 2010, in count
    return db._adapter.count(self.query, distinct)
  File "/home/ukitms/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1321, in count
    self.execute(self._count(query, distinct))
  File "/home/ukitms/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1388, in execute
    return self.log_execute(*a, **b)
  File "/home/ukitms/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1382, in log_execute
    ret = self.get_cursor().execute(command, *a[1:], **b)
OperationalError: database is locked

So I guess what I need to know is how to unlock this SQLite database? (Might migrate it to a MySQL database once this has been fixed, but one issue at a time.)

Is there a file called "my.db-journal" (where "my.db" is the name of your database file) in the same directory as the db file itself? If so, when was it last updated?

...actually, just to make that answer a little bit more complete -- if the file does exist, and it looks like it hasn't been updated for some time (say, since 1 December) then you can try renaming it, and see if that unlocks things.

I managed to unlock the db by making a copy of the database file and swapping that for the original.

I stopped looking here after I resolved the issue on my own, as except for the first reply above about restarting the task, I had received no feedback related to either this forum thread or my original feedback (in particular, no email of any kind). I have received "Scheduled downtime notifications" from that email address as recently as 10/18.

Sorry about that- did you receive the email we sent you 5 days ago where we mentioned that we try to keep an email response time of within 24 hours? (ie. we do not respond instantly to emails)