I have a script, run-web2py-scheduler-for-CABLE.py, to launch the web2py scheduler for my application, called CABLE:
#/usr/bin/env python
import os
import socket
import subprocess
import sys
filename = os.path.abspath(__file__) # we use this to generate a unique socket name
try:
# we use a local socket as a lock.
# it can only be bound once, and will be released if the process dies
socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM).bind('\0' + filename)
except socket.error:
print("Failed to acquire lock, task must already be running")
sys.exit()
subprocess.call(["python", "web2py/web2py.py", "-K", "CABLE"])
I have set up an hourly scheduled task: python run-web2py-scheduler-for-CABLE.py
It appears to be working: my website can process tasks using web2py's scheduler.
The strange thing to me is that when I view the list of Running Scheduled Tasks (by clicking Fetch Process List on the Schedule tab) I get a long list of processes, each with a "Kill" button attached. I thought the script would exit if it couldn't find a socket. I am confused: are multiple processes still running and consuming time? Are multiple workers engaged? That would be a problem because my scheduled tasks assume a single threaded operation. Can I safely ignore these multiple processes?
Here is the last few lines of the log file associated with the schedule:
ERROR:web2py.scheduler.giles-livetask1#24718:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#1659:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#17831:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#14512:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#426:Error retrieving status
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.9.12-stable+timestamp.2015.01.17.06.11.03
Database drivers available: sqlite3, pymysql, MySQLdb, mysqlconnector, psycopg2, pg8000, pyodbc, pymongo, imaplib
starting single-scheduler for "CABLE"...
ERROR:web2py.scheduler.giles-livetask1#24088:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#31150:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#31150:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#17831:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#426:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#24088:Error retrieving status
ERROR:web2py.scheduler.giles-livetask1#6635:Error retrieving status
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2015
Version 2.9.12-stable+timestamp.2015.01.17.06.11.03
Database drivers available: sqlite3, pymysql, MySQLdb, mysqlconnector, psycopg2, pg8000, pyodbc, pymongo, imaplib
starting single-scheduler for "CABLE"...
ERROR:web2py.scheduler.giles-livetask1#24088:Error retrieving status
Will someone educate me? Thank you!