Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError 'Job' object is not callable when running schedule within class #53

Closed
denchang opened this issue Aug 18, 2015 · 2 comments
Closed

Comments

@denchang
Copy link

Hi,

I need help with this code snippet. Below, I'm instantiating a schedule object within a class.
And from within the class I'm running my loop which I hope to run the scheduled job. It seems the "at" method won't accept the job I give it throwing a TypeError. Whereas running it every minute works fine.
In both cases assert statement does not fire. Can someone provide insight?

Thanks,
Dennis

import schedule
import time

class TestSchedule():

    def __init__(self):
        self.schedule = schedule

    def setup(self):
        ### WORKS ###
        # self.schedule.every(1).minutes.do(self.job)
        assert callable(self.job)
        ### DOESN'T WORK ###
        self.schedule.every().day().at("7:54").do(self.job)

    def job(self):
        print 'Job start at {0}'.format(time.strftime('%H:%M'))

    def loop(self):
        while 1:
            self.schedule.run_pending()
            print 'Sleeping for 10 sec'
            time.sleep(10)

if __name__ == '__main__':
    ts = TestSchedule()
    ts.setup()
    print 'Start schedule at {0}'.format(time.strftime('%H:%M'))
    ts.loop()
@WoLfulus
Copy link
Contributor

i don't know if this could be the issue, but "day" is a proerty, not a function

try

self.schedule.every().day.at("7:54").do(self.job)

@denchang
Copy link
Author

Thanks! You are correct.

self.schedule.every(1).days.at("8:35").do(self.job)

also works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants