Permalink
Browse files

Merge pull request #332 from jpfuentes2/fix_overzealous_shell_loop

Fix shell bug causing CPU 100%
  • Loading branch information...
2 parents 3ed9053 + f2a787c commit 50d2c9df612ea84562380e503a1ce64b5b734837 @carsomyr carsomyr committed Jan 21, 2013
Showing with 6 additions and 2 deletions.
  1. +3 −1 lib/capistrano/processable.rb
  2. +3 −1 lib/capistrano/shell.rb
@@ -23,6 +23,8 @@ def process_iteration(wait=nil, &block)
if readers.any? || writers.any?
readers, writers, = IO.select(readers, writers, nil, wait)
+ else
+ return false
end
if readers
@@ -50,4 +52,4 @@ def ensure_each_session
sessions
end
end
-end
+end
@@ -199,11 +199,13 @@ def reader
# thread and generally gets things ready for the REPL.
def setup
configuration.logger.level = Capistrano::Logger::INFO
+ wait_for = 0.1
@mutex = Mutex.new
@bgthread = Thread.new do
loop do
- @mutex.synchronize { process_iteration(0.1) }
+ ret = @mutex.synchronize { process_iteration(wait_for) }
+ sleep wait_for if !ret
end
end
end

0 comments on commit 50d2c9d

Please sign in to comment.