Skip to content

Commit 6e6ece7

Browse files
committed
Don't rescue ThreadError in FileThreadPool
The previous implementation was blindly catching all ThreadError exceptions, because that's what `#pop(true)` raises when the queue is empty. However, there are other situations that would raise the same class that we definitely shouldn't be silently ignoring. This changes the code to actually check if the queue is empty before popping, and removes the rescue entirely: if exceptions happen, we want to know.
1 parent de048cc commit 6e6ece7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/cc/engine/analyzers/file_thread_pool.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@ def run(&block)
1717

1818
@workers = thread_count.times.map do
1919
Thread.new do
20-
begin
21-
while item = queue.pop(true)
22-
yield item
23-
end
24-
rescue ThreadError
20+
while !queue.empty? && (item = queue.pop(true))
21+
yield item
2522
end
2623
end
2724
end

0 commit comments

Comments
 (0)