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

shutdown and execute a timertask results in double runs #672

Open
herwinw opened this issue Sep 6, 2017 · 1 comment · May be fixed by #1001
Open

shutdown and execute a timertask results in double runs #672

herwinw opened this issue Sep 6, 2017 · 1 comment · May be fixed by #1001
Labels
enhancement Adding features, adding tests, improving documentation. looking-for-contributor We are looking for a contributor to help with this issue. medium-priority Should be done soon.

Comments

@herwinw
Copy link

herwinw commented Sep 6, 2017

Script as PoC:

puts "Start: #{Time.now}"
task = Concurrent::TimerTask.execute(execution_interval: 3) { puts "In task: #{Time.now}" }
sleep 4
task.shutdown
puts "Restart: #{Time.now}"
task.execute
sleep 6
task.shutdown
puts "End: #{Time.now}"

Example output:

Start: 2017-09-06 12:24:54 +0200
In task: 2017-09-06 12:24:57 +0200
Restart: 2017-09-06 12:24:58 +0200
In task: 2017-09-06 12:25:00 +0200
In task: 2017-09-06 12:25:01 +0200
In task: 2017-09-06 12:25:03 +0200
End: 2017-09-06 12:25:04 +0200

The tekst "In task: 2017-09-06 12:25:00 +0200" is not what I would expect here, this belongs to the first execution. The combination of shutdown and execute results in 1 extra execution of the first timer.
if you create a new TimerTask instead, the pending task is not executed.


  • Operating system: linux
  • concurrent-ruby version: 1.0.5
  • concurrent-ruby-ext installed: yes
  • concurrent-ruby-edge used: no
@herwinw
Copy link
Author

herwinw commented Sep 6, 2017

To make it a bit more clear what I'm trying to do here: create a task that runs at a specific interval, but with an option to trigger a "run now", which would reset the countdown interval as well (so if a task is scheduled every 10 seconds starting at t, and at t+2 a "run now" is triggered, the next scheduled run would be at t+12, not t+10). That does require using run_now: true in the above example, but I prefered the minimal PoC. So maybe there's a simpler solution to this than what I'm trying to achieve.

@pitr-ch pitr-ch added the enhancement Adding features, adding tests, improving documentation. label Feb 25, 2018
@pitr-ch pitr-ch added this to the 1.1.0 milestone Feb 25, 2018
@pitr-ch pitr-ch added the minor label Jun 18, 2018
@pitr-ch pitr-ch added medium-priority Should be done soon. looking-for-contributor We are looking for a contributor to help with this issue. and removed minor labels Jun 29, 2018
@pitr-ch pitr-ch removed this from the 1.1.0 milestone Jul 6, 2018
@pitr-ch pitr-ch added this to TimeTask in Hackathon Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding features, adding tests, improving documentation. looking-for-contributor We are looking for a contributor to help with this issue. medium-priority Should be done soon.
Projects
Hackathon
TimeTask
2 participants