dbader / schedule

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

Problem after each schedule, gets delayed even with Parallel execution #564

Open pedrofaria09 opened 1 year ago

pedrofaria09 commented 1 year ago

Hello guys, I already searched and see many people are with problems because the schedule doesn't control the execution time, and the workaround for this is the Parallel execution: here Even after trying this, I still have the problem and even missed one call on date: 2023-02-15 21:03:11

Current Time = 2023-02-15 21:03:09.996591 <Thread(Thread-196 (test), started 123145329221632)> Current Time = 2023-02-15 21:03:10.999913 <Thread(Thread-197 (test), started 123145329221632)> Current Time = 2023-02-15 21:03:12.000702 <Thread(Thread-198 (test), started 123145329221632)> Current Time = 2023-02-15 21:03:13.002731 <Thread(Thread-199 (test), started 123145329221632)>

Can someone help me with this? I would appreciate it so much. my code:

import time
from datetime import datetime, timedelta
import threading

def test():
    current_time = datetime.now()
    print("Current Time =", current_time, threading.current_thread())

def run_threaded(job_func):
    job_thread = threading.Thread(target=job_func)
    job_thread.start()

schedule.every(1).seconds.do(run_threaded, test)

if __name__ == "__main__":
    while True:
        schedule.run_pending()
        time.sleep(1)
yxiao1996 commented 1 year ago

feel that it's working as expected:

  1. from this library's doc it mentions it's not supporting sub-second precision: https://schedule.readthedocs.io/en/stable/index.html
  2. I think your missed 2023-02-15 21:03:11 execution is actually 2023-02-15 21:03:10.999913
ghost commented 1 year ago

feel that it's working as expected:

  1. from this library's doc it mentions it's not supporting sub-second precision: https://schedule.readthedocs.io/en/stable/index.html
  2. I think your missed 2023-02-15 21:03:11 execution is actually 2023-02-15 21:03:10.999913

Yep that would be the problem 😜