You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require 'eventmachine'
require 'em-dir-watcher'
EM.kqueue = true if EM.kqueue?
EventMachine.run do
puts 'Watching .'
dw = EMDirWatcher.watch '.',
:include_only => ['*.html'],
:exclude => [],
:grace_period => 0.1 do |paths|
puts paths
end
puts 'Everything goes well so far'
EventMachine::Timer.new(10) do
puts 'Stoping EMDirWatcher. ruby CPU usage is 100% now. WTF?'
dw.stop
end
end
the ruby process is also using 100% of my CPU sometimes (I'm on a mac using mostly the FF extension).
the socket is probably running into a while(true), don't know how it was implemented and I'm not a ruby developer to look into it and solve the bug but I've seen it happening before, on that specific case the loop had a thread blocking operation (something related with I/O) when one of the sides of the socket disconnected that blocking operation didn't happened anymore, or happened too fast, so the loop was too short causing a result similar to a while(true).
If that is really the issue the way to solve it is to always enforce a delay of a few milliseconds before running the loop and kill the process after a couple seconds without any communication.
➤ ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.6.0]
The text was updated successfully, but these errors were encountered: