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 +4 -4
- data/lib/parallel.rb +11 -12
- data/lib/parallel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bb218d88e86c80e67ccbfd2d30e364fd23090d3ec0217aa8f7bab38cede2763
|
4
|
+
data.tar.gz: 5b0892050ecdb41322b9291398631a65439ce0edcf513ed46e4f49291407dafd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf31feef7f7556ebe43330e4beb1ef6370ec0d5392c312ed39abb59113ba7bd5878aa8d7c53ee002c2da61dabadb0cebce9bca12dea20094e7ed2297b96b054
|
7
|
+
data.tar.gz: 74781cc0d3f20acef7f437abc2f2ea5183f9c8f9e6f8dfd6399ba60dc5cf0f7828b3bfdc48028f143920d0e8bdc1777c83aaf965ac5557b562aace6e54c44473
|
data/lib/parallel.rb
CHANGED
@@ -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 =
|
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
|
-
|
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
|
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
|
402
|
+
worker.stop
|
404
403
|
end
|
405
404
|
end
|
406
405
|
end
|
data/lib/parallel/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|