python schedule package with init function
Question:
I need to create a init function, which needs to run before the scheduler starts. I am using the schedule package.
Is there an easy way to add an init function, which runs before the scheduler starts.
import schedule
def call_me():
print("I am invoked")
schedule.every(1).seconds.do(call_me)
while True:
schedule.run_pending()
Answers:
Directly invoke the function before using schedule
:
call_me()
schedule.every(1).seconds.do(call_me)
# ...
I need to create a init function, which needs to run before the scheduler starts. I am using the schedule package.
Is there an easy way to add an init function, which runs before the scheduler starts.
import schedule
def call_me():
print("I am invoked")
schedule.every(1).seconds.do(call_me)
while True:
schedule.run_pending()
Directly invoke the function before using schedule
:
call_me()
schedule.every(1).seconds.do(call_me)
# ...