You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of a question than bug report, but this phenomenon has been confusing me for years.
I guess a this is the appropriate place to ask about it.
So I have a script using schedule to check something periodically.
It roughly looks like this (pseudo code):
importtimeimportsysimportscheduledefcheck(url):
# print current time print(f"\nCurrent Time = {now_to_str()}")
# fetch and check `url` to see if it meets some conditions...ifnotcondition_met:
return# do something...returnschedule.CancelJobif__name__=='__main__':
schedule.every(26).seconds.do(check, url=sys.argv[1])
# run it immediately onceschedule.run_all()
whileschedule.jobs:
schedule.run_pending()
time.sleep(.1)
I will typically run three or four of such scripts in parallel (so different Python processes) on my machine. Because I do it manually, they usually start at different time, a few seconds apart.
What I've noticed that if I let the scripts run for a while, say 1 hour or 2, I find that the current time they print at the start of each task eventually became the same.
For example, I parsed the logs from three instances and print the difference between three logs:
As you can see, at the beginning 2 is 6 seconds behind 1, and 3 is 4 seconds behind 2.
But after merely 1 hours, they become in sync. And they STAY in sync for the rest of the time.
I fully understand schedule isn't meant to have exact timing, so I never expect the interval to be consistent. But I don't understand why would three totally unrelated python processes would eventually converge together.
In the above script I only have timestamp in seconds in my log. But in fact, they are more in sync than that!
In the actual full script, part of the scheduled task is to call a external program (subprocess.run) when the condition is met, which creates a folder called folder_{timestamp_in_ms}. And it has happens to me once, that two different running scripts create the folder at exactly same millisecond due to this convergence.
I can't for the life of me figure it out. I hope someone can provide some insights. Thanks in advance.
The text was updated successfully, but these errors were encountered:
fireattack
changed the title
Why did three separate python scripts using schedule started at different time eventually converged to be in sync?
Why did three separate python scripts using schedule start at different time eventually converged to be in sync?
Feb 23, 2024
This is more of a question than bug report, but this phenomenon has been confusing me for years.
I guess a this is the appropriate place to ask about it.
So I have a script using
schedule
to check something periodically.It roughly looks like this (pseudo code):
I will typically run three or four of such scripts in parallel (so different Python processes) on my machine. Because I do it manually, they usually start at different time, a few seconds apart.
What I've noticed that if I let the scripts run for a while, say 1 hour or 2, I find that the current time they print at the start of each task eventually became the same.
For example, I parsed the logs from three instances and print the difference between three logs:
As you can see, at the beginning 2 is 6 seconds behind 1, and 3 is 4 seconds behind 2.
But after merely 1 hours, they become in sync. And they STAY in sync for the rest of the time.
I fully understand schedule isn't meant to have exact timing, so I never expect the interval to be consistent. But I don't understand why would three totally unrelated python processes would eventually converge together.
In the above script I only have timestamp in seconds in my log. But in fact, they are more in sync than that!
In the actual full script, part of the scheduled task is to call a external program (
subprocess.run
) when the condition is met, which creates a folder calledfolder_{timestamp_in_ms}
. And it has happens to me once, that two different running scripts create the folder at exactly same millisecond due to this convergence.I can't for the life of me figure it out. I hope someone can provide some insights. Thanks in advance.
The text was updated successfully, but these errors were encountered: