Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using schedule module to reming me to drink water every ten seconds

I am using schedule module to remind me to drink water every ten seconds

import schedule


def remindDrink():
    print("Drink Water")
while True:
    schedule.every().day.at("16:35").do(remindDrink())

So the problem here is that the task gets executed, but immedieately, not at the given time, and VSCode throws a weird error at me

Traceback (most recent call last):
  File "e:\Code\Python Code\randomModule.py", line 12, in <module>
    schedule.every().day.at("16:31").do(sendNotification())
  File "C:\Users\PC\AppData\Local\Programs\Python\Python310\lib\site-packages\schedule\__init__.py", line 625, in do
    self.job_func = functools.partial(job_func, *args, **kwargs)
TypeError: the first argument must be callable
PS E:\Code\Python Code> 

This is the error, what am I doing wrong?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

from schedule import every, repeat, run_pending
import time

@repeat(every().day.at("16:35"))
def remindDrink():
    print("Drink Water")

while True:
    run_pending()
    time.sleep(1)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading