-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Race condition with timer signaling #12473
Comments
the problem is in the following code: > 620 function Timer(cb::Function, timeout::Real, repeat::Real=0.0)
621 t = Timer(timeout, repeat)
622 @schedule begin
623 while isopen(t)
624 wait(t)
625 isopen(t) && cb(t)
626 end
627 end
628 t
629 end since the timer is non-repeating, the edit: broken by fe62c2e @JeffBezanson |
May be the header could be changed to 'non-repeating timers are broken'. |
perhaps. the larger issue however is that having a conditional at fe62c2e#diff-ac5d350530574f3f82c860d1b963bc0aR624 incurs a race condition between the time that the timer is signaled, the time it is closed, and the time that this watcher got scheduled for execution. it's possible to create the same issues with repeating timers, the window of opportunity for failure is just much more obvious for single-shot timers. |
I think the best fix for now is to remove that extra condition, and call |
ref #12473, avoid swallowing other Timer callback errors
On the nightly 0.4.0-dev+5612, Timer() was working as intended, but since 0.4.0-dev+6210 it is broken.
Example:
Timer(x->println("hi"), 1, 0)
The text was updated successfully, but these errors were encountered: