dbader / schedule

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

Returning a value from a scheduled function #620

Closed padfoot96 closed 3 months ago

padfoot96 commented 3 months ago

I want to do something like this, wherein the scheduled function returns a value. How do I access this returned value?

`import schedule import time from datetime import datetime

def daily_function(str1): print("This function runs daily at 00:00 IST.") print("Daily function", str1)

Schedule the every_15_minutes_function after the daily_function

schedule.every(1).minutes.do(every_15_minutes_function)
return str1

def every_15_minutes_function(): print("This function runs every 15 minutes.")

schedule.every().day.at("19:03").do(daily_function, 'str1')

schedule.every(1).minutes.do(every_15_minutes_function)

while True:

# Checks whether a scheduled task 
# is pending to run or not
str1 = schedule.run_pending()
print(str1)
time.sleep(1)`