scheduled job only runs once - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: scheduled job only runs once (/thread-20559.html) |
scheduled job only runs once - Stan2292 - Aug-19-2019 import time import schedule def job(): import asdf_1 # "asdf_1" is a .py file that runs fine on its own schedule.every().day.at("13:00").do(job) while True: schedule.run_pending() time.sleep(1)the above code only runs once at the first 13:00 mark. it doesn't run the next day or the day after or ever. why? i know crontab is a more versatile (and perhaps reliable) scheduling module. but at this point i'm more curious why the "schedule" module doesn't work in this case. RE: scheduled job only runs once - fishhook - Aug-19-2019 Quote:why? def job(): import asdf_1All that you code do is importing module. Python's modules are imported only once per process. RE: scheduled job only runs once - Stan2292 - Aug-19-2019 (Aug-19-2019, 06:53 AM)fishhook Wrote:Quote:why?def job(): import asdf_1All that you code do is importing module. Python's modules are imported only once per process. would love to know the alternative... other than execfile of course... RE: scheduled job only runs once - buran - Aug-19-2019 refactor asdf_1? RE: scheduled job only runs once - fishhook - Aug-19-2019 (Aug-19-2019, 06:55 AM)Stan2292 Wrote: would love to know the alternative... other than execfile of course... importlib.reload(packagename) |