Created
December 27, 2017 05:59
-
-
Save linzino7/417a4221eac8310aca8f0e34102d6ceb to your computer and use it in GitHub Desktop.
Python APScheduler:TypeError: func must be a callable or a textual reference to one . Fix by __cell__.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Dec 26 16:18:35 2017 | |
@author: zino | |
""" | |
from datetime import datetime | |
import time | |
import os | |
from apscheduler.schedulers.background import BackgroundScheduler | |
class Foo: | |
def __init__(self,n): | |
self.name=n | |
def __call__(self): | |
self.tk(self.name) | |
def tk(self,name): | |
print('Tick%s! The time is: %s' % (name,datetime.now())) | |
if __name__ == '__main__': | |
scheduler = BackgroundScheduler() | |
for i in range(1,5): | |
scheduler.add_job(Foo(i), 'interval', seconds=i) | |
scheduler.start() | |
try: | |
while True: | |
time.sleep(2) | |
except (KeyboardInterrupt, SystemExit): | |
print('exit') | |
scheduler.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment