multi_process 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +6 -6
- data/CHANGELOG.md +17 -1
- data/Gemfile +1 -1
- data/README.md +6 -6
- data/lib/multi_process/group.rb +1 -1
- data/lib/multi_process/process.rb +6 -4
- data/lib/multi_process/version.rb +1 -1
- data/multi_process.gemspec +0 -4
- data/spec/multi_process_spec.rb +19 -0
- metadata +4 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d62d4ef2d14471f23abcd7c7015d4370acffba45c77007df13505dd96e9fd16
|
4
|
+
data.tar.gz: 479e3d12ed873435fcdebe1d8d1d37bab3fbd276f5db85bdb079fa0264bbae27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5865c7397ca0cfcdc7b91c4d1e02f573b85dd63e1b1876074c49d1e5e3595926e6ef9d04d49b0cf0863be3e7c7bdbef814f7fb04a0f389308484847442b699e6
|
7
|
+
data.tar.gz: c15f75913b1b3824386430e90202700ff2ac261f3ec09e4db46a52b9d2d639c3eda54102c00e3058bcdca01d1ffde87b4b79febe4d59474d99a86d889ba534e2
|
data/.github/workflows/test.yml
CHANGED
@@ -5,15 +5,15 @@ on: push
|
|
5
5
|
jobs:
|
6
6
|
rspec:
|
7
7
|
name: ruby-${{ matrix.ruby }}
|
8
|
-
runs-on: ubuntu-
|
8
|
+
runs-on: ubuntu-22.04
|
9
9
|
|
10
10
|
strategy:
|
11
11
|
fail-fast: false
|
12
12
|
matrix:
|
13
|
-
ruby: ["3.1", "3.0", "2.7"]
|
13
|
+
ruby: ["3.2", "3.1", "3.0", "2.7"]
|
14
14
|
|
15
15
|
steps:
|
16
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
17
17
|
- uses: ruby/setup-ruby@v1
|
18
18
|
with:
|
19
19
|
ruby-version: ${{ matrix.ruby }}
|
@@ -23,13 +23,13 @@ jobs:
|
|
23
23
|
|
24
24
|
rubocop:
|
25
25
|
name: rubocop
|
26
|
-
runs-on: ubuntu-
|
26
|
+
runs-on: ubuntu-22.04
|
27
27
|
|
28
28
|
steps:
|
29
|
-
- uses: actions/checkout@
|
29
|
+
- uses: actions/checkout@v4
|
30
30
|
- uses: ruby/setup-ruby@v1
|
31
31
|
with:
|
32
|
-
ruby-version: 3.
|
32
|
+
ruby-version: "3.2"
|
33
33
|
bundler-cache: True
|
34
34
|
env:
|
35
35
|
BUNDLE_JOBS: 4
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Use unbundled environment for child processes to support nested bundler invokations by @tylerhunt (#10)
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Fix adding a process after the group has been started by @tylerhunt (#11)
|
16
|
+
|
17
|
+
## [1.2.1] - 2024-01-11
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- Remove dependency on ActiveSupport by @tylerhunt (#9)
|
22
|
+
- Ruby 3.2
|
23
|
+
|
9
24
|
## [1.2.0] - 2022-06-03
|
10
25
|
|
11
26
|
### Added
|
@@ -30,7 +45,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
30
45
|
|
31
46
|
- Possible concurrent hash modification while iterating (#1)
|
32
47
|
|
33
|
-
[
|
48
|
+
[Unreleased]: https://github.com/jgraichen/multi_process/compare/v1.2.1...HEAD
|
49
|
+
[1.2.1]: https://github.com/jgraichen/multi_process/compare/v1.2.0...v1.2.1
|
34
50
|
[1.2.0]: https://github.com/jgraichen/multi_process/compare/v1.1.1...v1.2.0
|
35
51
|
[1.1.1]: https://github.com/jgraichen/multi_process/compare/v1.1.0...v1.1.1
|
36
52
|
[1.1.0]: https://github.com/jgraichen/multi_process/compare/v1.0.0...v1.1.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -12,14 +12,14 @@ gem 'multi_process'
|
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
|
-
```
|
16
|
-
|
15
|
+
```console
|
16
|
+
bundle
|
17
17
|
```
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
```
|
22
|
-
|
21
|
+
```console
|
22
|
+
gem install multi_process
|
23
23
|
```
|
24
24
|
|
25
25
|
## Usage
|
@@ -36,7 +36,7 @@ group.wait # Wait until finished
|
|
36
36
|
group.stop # Stop processes
|
37
37
|
```
|
38
38
|
|
39
|
-
```
|
39
|
+
```text
|
40
40
|
(23311) rubyB | Output from B
|
41
41
|
(23308) rubyA | Output from A
|
42
42
|
(23314) rubyC | Output from C
|
@@ -55,7 +55,7 @@ group.stop # Stop processes
|
|
55
55
|
|
56
56
|
## License
|
57
57
|
|
58
|
-
Copyright © 2019 Jan Graichen
|
58
|
+
Copyright © 2019-2023 Jan Graichen
|
59
59
|
|
60
60
|
This program is free software: you can redistribute it and/or modify
|
61
61
|
it under the terms of the GNU General Public License as published by
|
data/lib/multi_process/group.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'forwardable'
|
4
4
|
|
5
5
|
module MultiProcess
|
6
6
|
#
|
@@ -9,6 +9,8 @@ module MultiProcess
|
|
9
9
|
# {Process} basically is just a thin wrapper around {ChildProcess}.
|
10
10
|
#
|
11
11
|
class Process
|
12
|
+
extend Forwardable
|
13
|
+
|
12
14
|
# @!group Process
|
13
15
|
|
14
16
|
# Process title used in e.g. logger
|
@@ -39,7 +41,7 @@ module MultiProcess
|
|
39
41
|
|
40
42
|
# Delegate some methods to ChildProcess.
|
41
43
|
#
|
42
|
-
delegate
|
44
|
+
delegate %i[exited? alive? crashed? exit_code pid] => :childprocess
|
43
45
|
|
44
46
|
# Wait until process finished.
|
45
47
|
#
|
@@ -159,7 +161,7 @@ module MultiProcess
|
|
159
161
|
# Check if environment will be cleaned up for process.
|
160
162
|
#
|
161
163
|
# Currently that includes wrapping the process start in
|
162
|
-
# `Bundler.
|
164
|
+
# `Bundler.with_unbundled_env` to remove bundler environment
|
163
165
|
# variables.
|
164
166
|
#
|
165
167
|
def clean_env?
|
@@ -216,7 +218,7 @@ module MultiProcess
|
|
216
218
|
childprocess.cwd = dir
|
217
219
|
|
218
220
|
if clean_env?
|
219
|
-
Bundler.
|
221
|
+
Bundler.with_unbundled_env { childprocess.start }
|
220
222
|
else
|
221
223
|
childprocess.start
|
222
224
|
end
|
data/multi_process.gemspec
CHANGED
@@ -19,12 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0")
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
22
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
22
|
spec.require_paths = ['lib']
|
24
23
|
|
25
|
-
spec.add_runtime_dependency 'activesupport', '>= 3.1'
|
26
24
|
spec.add_runtime_dependency 'childprocess'
|
27
25
|
spec.add_runtime_dependency 'nio4r', '~> 2.0'
|
28
|
-
|
29
|
-
spec.add_development_dependency 'bundler'
|
30
26
|
end
|
data/spec/multi_process_spec.rb
CHANGED
@@ -40,6 +40,25 @@ describe MultiProcess do
|
|
40
40
|
expect(Time.now - start).to be < 2
|
41
41
|
end
|
42
42
|
|
43
|
+
it 'starts a process added after the group has been started' do
|
44
|
+
reader, writer = IO.pipe
|
45
|
+
|
46
|
+
logger = MultiProcess::Logger.new writer, collapse: false
|
47
|
+
group = MultiProcess::Group.new receiver: logger
|
48
|
+
group << MultiProcess::Process.new(%w[ruby spec/files/test.rb 1], title: 'ruby1')
|
49
|
+
group.start
|
50
|
+
group << MultiProcess::Process.new(%w[ruby spec/files/test.rb 2], title: 'ruby2')
|
51
|
+
sleep 1
|
52
|
+
group.stop
|
53
|
+
|
54
|
+
expect(reader.read_nonblock(4096).split("\n")).to match_array <<-OUTPUT.gsub(/^\s+\./, '').split("\n")
|
55
|
+
. ruby1 | Output from 1
|
56
|
+
. ruby1 | Output from 1
|
57
|
+
. ruby2 | Output from 2
|
58
|
+
. ruby2 | Output from 2
|
59
|
+
OUTPUT
|
60
|
+
end
|
61
|
+
|
43
62
|
it 'partitions processes' do
|
44
63
|
group = MultiProcess::Group.new partition: 4, receiver: MultiProcess::NilReceiver.new
|
45
64
|
group << MultiProcess::Process.new(%w[ruby sleep.rb 1], dir: 'spec/files', title: 'rubyA')
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_process
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.1'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.1'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: childprocess
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +38,6 @@ dependencies:
|
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '2.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
41
|
description: Handle multiple child processes.
|
70
42
|
email:
|
71
43
|
- jg@altimos.de
|
@@ -124,16 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
96
|
- !ruby/object:Gem::Version
|
125
97
|
version: '0'
|
126
98
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
99
|
+
rubygems_version: 3.4.22
|
128
100
|
signing_key:
|
129
101
|
specification_version: 4
|
130
102
|
summary: Handle multiple child processes.
|
131
|
-
test_files:
|
132
|
-
- spec/files/env.rb
|
133
|
-
- spec/files/fail.rb
|
134
|
-
- spec/files/sleep.rb
|
135
|
-
- spec/files/test.rb
|
136
|
-
- spec/multi_process/group_spec.rb
|
137
|
-
- spec/multi_process/process_spec.rb
|
138
|
-
- spec/multi_process_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
103
|
+
test_files: []
|