parallel 1.14.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 587c7508b0e181ee03b60b9641ac9afa3feaa09a2fe3af0e6fc52d11ecf22338
4
- data.tar.gz: 9e4fafeb97a74277aa33276dbb4383ee5227b26553eca719af4a5ca4fd8daa0d
3
+ metadata.gz: 8bb218d88e86c80e67ccbfd2d30e364fd23090d3ec0217aa8f7bab38cede2763
4
+ data.tar.gz: 5b0892050ecdb41322b9291398631a65439ce0edcf513ed46e4f49291407dafd
5
5
  SHA512:
6
- metadata.gz: 411d4eb1d0f9387327c7778588eb2337280031739c4237b9123ab1ad995c7f9ec53312c2887e65df61203451061a9b318d2e23ea08a94ff727714ae2067a4c78
7
- data.tar.gz: 57719ea9cd17ce0b82470aeb1128344fda823ce7f28779aa2ff6cc4f7581583bf3db2e86418f59d9926fcc7e8124edb0643bf95930cdf6410f73d586ea0c47f9
6
+ metadata.gz: 8cf31feef7f7556ebe43330e4beb1ef6370ec0d5392c312ed39abb59113ba7bd5878aa8d7c53ee002c2da61dabadb0cebce9bca12dea20094e7ed2297b96b054
7
+ data.tar.gz: 74781cc0d3f20acef7f437abc2f2ea5183f9c8f9e6f8dfd6399ba60dc5cf0f7828b3bfdc48028f143920d0e8bdc1777c83aaf965ac5557b562aace6e54c44473
@@ -283,6 +283,7 @@ module Parallel
283
283
  Thread.current[:parallel_worker_number]
284
284
  end
285
285
 
286
+ # TODO: this does not work when doing threads in forks, so should remove and yield the number instead if needed
286
287
  def worker_number=(worker_num)
287
288
  Thread.current[:parallel_worker_number] = worker_num
288
289
  end
@@ -359,11 +360,7 @@ module Parallel
359
360
  end
360
361
 
361
362
  def work_in_processes(job_factory, options, &blk)
362
- workers = if options[:isolation]
363
- [] # we create workers per job and not beforehand
364
- else
365
- create_workers(job_factory, options, &blk)
366
- end
363
+ workers = create_workers(job_factory, options, &blk)
367
364
  results = []
368
365
  results_mutex = Mutex.new # arrays are not thread-safe
369
366
  exception = nil
@@ -371,6 +368,7 @@ module Parallel
371
368
  UserInterruptHandler.kill_on_ctrl_c(workers.map(&:pid), options) do
372
369
  in_threads(options) do |i|
373
370
  worker = workers[i]
371
+ worker.thread = Thread.current
374
372
 
375
373
  begin
376
374
  loop do
@@ -379,28 +377,29 @@ module Parallel
379
377
  break unless index
380
378
 
381
379
  if options[:isolation]
382
- worker = replace_worker(job_factory, workers, i, options, blk)
380
+ lap ||= 0
381
+ lap += 1
382
+ replace_worker(job_factory, workers, i, options, blk) if lap > 1
383
+ worker.thread = Thread.current
383
384
  end
384
385
 
385
- worker.thread = Thread.current
386
-
387
386
  begin
388
387
  result = with_instrumentation item, index, options do
389
388
  worker.work(job_factory.pack(item, index))
390
389
  end
391
390
  results_mutex.synchronize { results[index] = result } # arrays are not threads safe on jRuby
392
- rescue
393
- exception = $!
391
+ rescue StandardError => e
392
+ exception = e
394
393
  if Parallel::Kill === exception
395
394
  (workers - [worker]).each do |w|
396
- w.thread.kill unless w.thread.nil?
395
+ w.thread.kill if w.thread
397
396
  UserInterruptHandler.kill(w.pid)
398
397
  end
399
398
  end
400
399
  end
401
400
  end
402
401
  ensure
403
- worker.stop if worker
402
+ worker.stop
404
403
  end
405
404
  end
406
405
  end
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '1.14.0'
2
+ VERSION = Version = '1.15.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2019-03-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it