dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.62k stars 954 forks source link

"'float' object is not callable" when using Scheduler Class #580

Closed dudumiquim closed 1 year ago

dudumiquim commented 1 year ago

I'm testing the code above, trying to get the idle_seconds:

import schedule, time

def my_job():
    print("Running.")

aux_sched = schedule.Scheduler()
aux_sched.every(2).seconds.do(my_job)

while 1:
    aux_sched.idle_seconds()
    aux_sched.run_pending()
    time.sleep(0.5)

But when I'm using a new object of Scheduler Class, I'm getting this error:

Traceback (most recent call last):
  File "[ommited]/example.py", line 11, in <module>
    aux_sched.idle_seconds()
TypeError: 'float' object is not callable

Someone know how to fix it?

Env: Python 3.9.16 Schedule 1.2.0 CentOS 9

SijmenHuizenga commented 1 year ago

When having a instance of the Scheduler Class, use the idle_seconds property instead of the idle_seconds() function. This should work:

aux_sched.idle_seconds