Permalink
Browse files

Fix timeout issue when popping results

  • Loading branch information...
1 parent b4c710c commit 384a3f2195892978bee537ea9ed4bf6797669804 @brynary committed Sep 14, 2009
Showing with 16 additions and 11 deletions.
  1. +3 −11 lib/testjour/commands/run.rb
  2. +13 −0 lib/testjour/http_queue.rb
@@ -93,17 +93,9 @@ def testjour_yml_args
def print_results
results_formatter = ResultsFormatter.new(step_counter, configuration.options)
queue = RedisQueue.new
- results_count = 0
-
- Timeout.timeout(180) do
- while results_count < step_counter.count
- if (result = queue.pop(:results))
- results_formatter.result(result)
- results_count += 1
- else
- sleep 0.1
- end
- end
+
+ step_counter.count.times do
+ results_formatter.result(queue.blocking_pop(:results))
end
results_formatter.finish
View
@@ -27,6 +27,19 @@ def pop(queue_name)
result ? Marshal.load(result) : nil
end
+ def blocking_pop(queue_name)
+ Timeout.timeout(180) do
+ result = nil
+
+ while result.nil?
+ result = pop(queue_name)
+ sleep 0.1 unless result
+ end
+
+ result
+ end
+ end
+
end
end

0 comments on commit 384a3f2

Please sign in to comment.