Reputation: 658
I want to use apscheduler.scheduler
in my project and this is my code
import sys
from time import sleep
from apscheduler.scheduler import Scheduler
TOKEN = "****"
sched = Scheduler()
sched.start()
def my_job(text):
print(text)
def main() :
job = sched.add_date_job(my_job('25'), '2017-09-08 14:08:05', args=['text'])
while True:
sleep(1)
sys.stdout.write('.'); sys.stdout.flush()
if __name__ == '__main__':
main()
and I got this exception
25
Traceback (most recent call last):
File "F:\+faeze\workspace\testHelloWorld\src\test\testDateTime.py", line 22, in <module>
main()
File "F:\+faeze\workspace\testHelloWorld\src\test\testDateTime.py", line 16, in main
job = sched.add_date_job(my_job('25'), '2017-09-08 14:08:05', args=['text'])
File "C:\Python27\lib\site-packages\apscheduler\scheduler.py", line 318, in add_date_job
return self.add_job(trigger, func, args, kwargs, **options)
File "C:\Python27\lib\site-packages\apscheduler\scheduler.py", line 284, in add_job
options.pop('coalesce', self.coalesce), **options)
File "C:\Python27\lib\site-packages\apscheduler\job.py", line 47, in __init__
raise TypeError('func must be callable')
TypeError: func must be callable
where is my mistake??
update: what does TypeError: func must be callable
mean?
Upvotes: 2
Views: 3177
Reputation: 2003
You should modify the following line.
job = sched.add_date_job(my_job, '2017-09-08 14:08:05', ('25',))
This means my_job method will be called at the specified time with argument 25
Upvotes: 3