run_continuously() mentioned in docs, but not in source
This section of the documentation mentions source in a fork of scheduler: https://github.com/dbader/schedule/blob/master/FAQ.rst#how-to-continuously-run-the-scheduler-without-blocking-the-main-thread https://github.com/mrhwick/schedule/blob/master/schedule/init.py
So why not include this in the library? I installed from https://github.com/mrhwick/schedule/ to get the run_continuously() function, but then realized the fork does not include other things mentioned in the documentation, such as CancelJob ( https://github.com/dbader/schedule/blob/master/FAQ.rst#how-can-i-run-a-job-only-once )
Any update on this?
My experience with run_countinuosly() approach.
I'm running schedule module in a chatbot to propagate to a certain set of channels a few messages, the chatbot library I'm using heavily relies on event loops and asyncio framework. By adopting the run_countinuosly() approach in that context I found that I wasn't able to stop the infinite loop in the thread without implementing a listener on the SIGINT signal, which was a dirty approach from my point of view.
Said this I think it's ok not to include a standard approach to call run_pending() with the needed frequence: the way is invoked should be adapted on the context in which the application is running.
Said this I think it's ok not to include a standard approach to call run_pending() with the needed frequence: the way is invoked should be adapted on the context in which the application is running.
I agree – there have been proposals to do this in the past but it's super hard to find an approach that will work for most use cases... My approach has been to try and make it relatively hard for people to shoot themselves in the foot with schedule, e.g by discouraging its use as a cron replacement or adding a pre-baked run_continously.
My thinking is that a possible solution is to have better docs (see #4).
Any thoughts on that matter?
For the record, I use this:
class ScheduleThread(threading.Thread):
def __init__(self, *pargs, **kwargs):
super().__init__(*pargs, daemon=True, name="scheduler", **kwargs)
def run(self):
while True:
schedule.run_pending()
time.sleep(schedule.idle_seconds())
ScheduleThread().start()
It runs in the background, doesn't require configuration or additional work, and doesn't keep the python interpreter open.
I developed this in conjunction with a work queue, which is still necessary if your system has one (or if you need to be called from the context of an event loop, etc.) That is, you still need to say schedule.every().hour.do(myqueue.add, myjob) or schedule.every().hour.do(loop.idle_add, myjob), but I feel like that's a different problem.
run_continuously has been described more clearly in the docs (see latest version). Feel free to open a new issue if things are still unclear :+1: