-
Notifications
You must be signed in to change notification settings - Fork 419
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
TimerTask#execute is not a blocking call #794
Comments
Did you run the example in IRB or as a stand-alone Ruby script? When Ruby reaches the end of a script it immediately exits, killing all threads, destroying all objects, and releasing all its resources. None of the abstractions in this gem prevent this from happening. (This is by design. We don't want buggy code to ever prevent Ruby from exiting.) So if you ran this as a stand-alone script then Ruby would have exited immediately after your call to If you want to runs this as a stand-alone script and have Ruby not exit until the tasks are done, one option is to use an |
I ran this example as a stand-alone ruby script. timer_task.execute # blocking call - this task will stop itself which made it sound like the script would block on that line until the task was shutdown (from within the task itself). I noticed that the script did not block on that line and was asking whether timer_task.execute was supposed to be non-blocking (example is incorrect) or whether it was supposed to be blocking (behavior is incorrect). |
So if it is expected behavior that ruby exits right after |
|
timer_task.execute # blocking call ... Maybe I'm getting confused but the two statements above don't seem to be saying the same thing... How about changing that line in the example to: timer_task.execute # this task will stop itself Thoughts? |
I cannot get the example to print anything, not sure what is going on. I'll revisit it. |
@ajlai are you still interested in this issue? |
Hi,
I was looking through the TimerTask examples and noticed that the one below isn't working as documented:
If I put those contents into a file and run it via
ruby timer_task_boom_test.rb
, it exits immediately. If I add asleep
right after the timer_task.execute line then I see theBoom!
s printed out.Is timer_task.execute supposed to be a blocking call? Or has the behavior changed and this example is no longer valid?
more info
The text was updated successfully, but these errors were encountered: