Skip to content
Kurt Grutzmacher edited this page Feb 1, 2014 · 2 revisions

Overview

The web2py Scheduler is utilized by Kvasir to handle long-running tasks and actions that require user interaction with a shell (terminal launching). More details on the inner workings of the scheduler can be found at the web2py documentation.

Scheduler tasks

Group names

Kvasir groups tasks into unique names based upon the hostname so that tasks kicked off by one web2py instance will run on that user's web2py scheduler instance on the same machine. The scehduler_group_name variable in kvasir.yaml can be set to force a specific name, otherwise the hostname is used.

Troubleshooting long-queued tasks

If you find a task has been queued for some time look for the following

Is the web2py scheduler running on the same host as the web2py server?

$ ./web2py.py -K kvasir,kvasir
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.5.1-stable+timestamp.2013.06.06.15.39.19
Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(psycopg2), PostgreSQL(pg8000), MongoDB(pymongo), IMAP(imaplib)
starting scheduler for "kvasir"...
Currently running 1 scheduler processes
Processes started
starting scheduler for "kvasir"...
Currently running 2 scheduler processes
Processes started

Obtain the hostname from python and compare it with the assigned group names in tasks/index.html:

$ python -c 'import socket; print socket.gethostname()'
myhostname

Controlling Worker States

Any ACTIVE scheduler worker can be terminated in one of three ways:

  • KILL
  • TERMINATE
  • DISABLE

KILL

Kill is equal to doing a Ctrl-C on a process and will kill the worker process immediately.

TERMINATE

Worker will die as soon as it can. If a task is being processed it will wait till that task is finished.

DISABLE

Will progressively sleep the worker process for heartbeat*10 seconds (50 seconds by default).