Skip to content
Kurt Grutzmacher edited this page Sep 23, 2013 · 1 revision

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 group name is configured in models/db.py:

settings.scheduler_group_name = socket.gethostname()
settings.scheduler_worker_name = settings.scheduler_group_name

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).