Skip to content
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

discard_past doesn't seem to be working for "every" jobs with max_work_threads #343

Open
rscarborough1996 opened this issue Aug 24, 2023 · 1 comment
Assignees

Comments

@rscarborough1996
Copy link

rscarborough1996 commented Aug 24, 2023

Hello,

When an "every" job is delayed due to max_work_threads limit being reached, it will run multiple times when it finally gets the chance, which I would expect discard_past to prevent.

Example:

require 'rufus-scheduler'

scheduler = Rufus::Scheduler.new(max_work_threads: 1, discard_past: true)


scheduler.in '1s' do
  sleep 5
  puts "job finished #{Time.now}"
end

scheduler.every '1s' do
  puts "tick #{Time.now}"
end

scheduler.join

The above code will produce something like this:

job finished 2023-08-24 17:22:14 -0400
tick 2023-08-24 17:22:14 -0400
tick 2023-08-24 17:22:14 -0400
tick 2023-08-24 17:22:14 -0400
tick 2023-08-24 17:22:14 -0400
tick 2023-08-24 17:22:14 -0400
tick 2023-08-24 17:22:15 -0400
tick 2023-08-24 17:22:17 -0400
tick 2023-08-24 17:22:18 -0400
...

As you can see, multiple "ticks" occur at once.
Is there a work around, or perhaps I am missing something?

Thanks

System:
ruby 3.0.2
rufus-scheduler 3.9.1
running in wsl2 Ubuntu

@jmettraux jmettraux self-assigned this Aug 24, 2023
@jmettraux
Copy link
Owner

I did not forget this one. I think it needs some rework. Give me please a bit more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants