schedule icon indicating copy to clipboard operation
schedule copied to clipboard

Problem after each schedule, gets delayed even with Parallel execution

Open pedrofaria09 opened this issue 2 years ago • 2 comments

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)

pedrofaria09 avatar Feb 15 '23 21:02 pedrofaria09

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

yxiao1996 avatar Feb 18 '23 19:02 yxiao1996

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 😜

ghost avatar Jul 03 '23 16:07 ghost