I am using apscheduler and I am trying to pass in parameters to the handler function that gets called when the scheduled job is launched:
from apscheduler.scheduler import Scheduler
import time
def printit(sometext):
print "this happens every 5 seconds"
print sometext
sched = Scheduler()
sched.start()
sometext = "this is a passed message"
sched.add_cron_job(printit(sometext), second="*/5")
while True:
time.sleep(1)
Doing this gives me the following error:
TypeError: func must be callable
Is it possible to pass parameters into the function handler. If not, are there any alternatives? Basically, I need each scheduled job to return a string that I pass in when I create the schedule. Thanks!