-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
job skipping semantics too subtle and scary? #66
Comments
I'll try to answer this to the best of my ability, since I recently butted my head against a similar issue, and maybe it will help someone reading this later :) Will one of these always not run?No, both of them may (and very likely will) both run. To explain why, we have to take a look at how Clockwork actually schedules its jobs. This is a very simplified Ruby-pseudocode explanation of how Clockwork's main loop works (according to my already simplified understanding): def main_loop
loop do
t = Time.now
tick(t)
sleep(1)
end
end
def tick(t)
# NOTE: Assuming that all events have an 'at:' option -- otherwise, hour/minute is not checked
events_to_run = events.select { |e| e.run_at.past? && e.hour == t.hour && e.min == t.min }
events.each do |event|
event.run
end
end The crucial thing to note here is that at every That doesn't mean that both events will start executing at 16:20. Clockwork is single-threaded by default1, which means that if the first job takes an hour, the second won't start executing until 17:20 -- but eventually it will run when the first job finishes. So when is the
|
the readme says:
Whoah! That's quite a significant thing to happen silently because another job is running. If threading solves it completely, that's great! But that's also not super clear.
Will one of these always not run?
Will both of these always run?
The text was updated successfully, but these errors were encountered: