-
Notifications
You must be signed in to change notification settings - Fork 64
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
stop will not stop immediately. it will stop after the next event #47
Comments
Perhaps with an option the run loop could be using IO.select, or something like that. |
For completeness, here's a failing example on JRuby: require 'rb-inotify'
Thread.new do
INotify::Notifier.new.tap do |notifier|
Thread.current[:notifier] = notifier
notifier.watch("/tmp", :modify) { |changes| puts changes.inspect }
notifier.run
end
end.run
sleep 3
th[:notifier].close
th.join
# Never gets here - stuck unless an inotify event occurs Any workaround possible? Any way to reliably trigger or simulate an inotify event? |
I think that right now, this behaviour is outside the scope of the current implementation. The correct solution, is for notifier.run to call select with a wakeup pipe, and for stop to send a single byte down that pipe. I think this belongs elsewhere, e.g. https://github.com/socketry/async/blob/04b3fdae3fa41300777d197b09db54f7ac1d7e2d/lib/async/reactor.rb#L122 |
If you have no events coming in, then calling
stop
after callingrun
in a separate thread will not causerun
to unblock. Instead, it will only stop after another event has been processed.The text was updated successfully, but these errors were encountered: