diff options
author | Homu <homu@barosl.com> | 2016-01-31 16:41:21 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-01-31 16:41:21 +0900 |
commit | bf42ae18cea8bf800318f06278e0f718692dec21 (patch) | |
tree | c512f8c4462e3167d2bad681bc9138872cbbe071 | |
parent | 84c071906f44f2517ff096a7a5ad80c7cf457c8b (diff) | |
parent | a6e2bbaa9c5ee97787b141748e656a4e5ff37aa3 (diff) | |
download | bundler-bf42ae18cea8bf800318f06278e0f718692dec21.tar.gz |
Auto merge of #4254 - bundler:seg-thread-names, r=indirect
[Worker] Add a worker name to ease debugging
Also helps with https://github.com/bundler/bundler/issues/4246.
@indirect r?
-rwxr-xr-x | bin/rake | 4 | ||||
-rwxr-xr-x | bin/rspec | 4 | ||||
-rwxr-xr-x | bin/rubocop | 5 | ||||
-rw-r--r-- | lib/bundler/fetcher/compact_index.rb | 3 | ||||
-rw-r--r-- | lib/bundler/installer/parallel_installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/worker.rb | 13 |
6 files changed, 27 insertions, 4 deletions
@@ -11,4 +11,8 @@ bundler_spec.dependencies.each do |dep| end end +Gem::Specification.unresolved_deps.each do |_name, dep| + gem dep.name, *dep.requirement +end + load Gem.bin_path("rake", "rake") @@ -7,4 +7,8 @@ bundler_spec.dependencies.each do |dep| gem dep.name, dep.requirement.to_s end +Gem::Specification.unresolved_deps.each do |_name, dep| + gem dep.name, *dep.requirement +end + load Gem.bin_path("rspec-core", "rspec") diff --git a/bin/rubocop b/bin/rubocop index 404e05888b..8142053393 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -8,4 +8,9 @@ bundler_spec.dependencies.each do |dep| end gem "rubocop", "= 0.35.1" + +Gem::Specification.unresolved_deps.each do |_name, dep| + gem dep.name, *dep.requirement +end + load Gem.bin_path("rubocop", "rubocop") diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index 97b2e71dce..0dd9b130be 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -80,7 +80,8 @@ module Bundler end.tap do |client| client.in_parallel = lambda do |inputs, &blk| func = lambda {|object, _index| blk.call(object) } - worker = Bundler::Worker.new(25, func) + worker_name = "Compact Index (#{display_uri.host})" + worker = Bundler::Worker.new(25, worker_name, func) inputs.each {|input| worker.enq(input) } inputs.map { worker.deq } end diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index d32204fab3..674c45af25 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -84,7 +84,7 @@ class ParallelInstaller end def worker_pool - @worker_pool ||= Bundler::Worker.new @size, lambda { |spec_install, worker_num| + @worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda { |spec_install, worker_num| message = Bundler::GemInstaller.new( spec_install.spec, @installer, @standalone, worker_num, @force ).install_from_spec diff --git a/lib/bundler/worker.rb b/lib/bundler/worker.rb index da7eac0b69..addd9cc8a1 100644 --- a/lib/bundler/worker.rb +++ b/lib/bundler/worker.rb @@ -11,15 +11,24 @@ module Bundler end end + # @return [String] the name of the worker + attr_reader :name + # Creates a worker pool of specified size # # @param size [Integer] Size of pool + # @param name [String] name the name of the worker # @param func [Proc] job to run in inside the worker pool - def initialize(size, func) + def initialize(size, name, func) + @name = name @request_queue = Queue.new @response_queue = Queue.new @func = func - @threads = size.times.map {|i| Thread.start { process_queue(i) } } + @threads = size.times.map do |i| + Thread.start { process_queue(i) }.tap do |thread| + thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=) + end + end trap("INT") { abort_threads } end |