in-parallel 0.1.17 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +160 -0
- data/CODEOWNERS +8 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +76 -0
- data/README.md +42 -7
- data/lib/in-parallel/version.rb +1 -1
- data/lib/in_parallel.rb +2 -2
- data/spec/in-paralell_spec.rb +4 -4
- metadata +8 -7
- data/MAINTAINERS.md +0 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NzQ4MzE5Yjk0NDc5NjY3YjUxOWM4ODY0NGE2NTk5ZWJiNmY0NWQwMA==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9e6a5a0525683fb244fb9bfcca580705f721eae4e8bd7331b1fa3f2483a26bbf
|
4
|
+
data.tar.gz: d78dce34586e1c391b4285cd075cecadf80d735eaee7a41d506894b9cc55031f
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MTE5NDI0OGYzMzQ4MzNhNDdkOGYyZDBkYTBmOTgxNDQ2ZWU1Zjc1YmUzNDQy
|
11
|
-
OWU2NTJiODYzODE5NWUxODVlOTQ0MjMzZjM1ZWQ4NGE3YWJjMGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Y2UyNDhlZjFjNWQzZjNkMWMyOTVlNjljZjkzOWJhZWQ2ZDM1MmUwNTNlNTJm
|
14
|
-
NDY4MTBhYjVmMGJkMzAzMDU0OWE0NDMwZDA1ODc4MGFkZjNjZWQ5ZDBlOGZm
|
15
|
-
NTYxYjVlZGZkYTFjN2NlNTIxZGJmOGJlYjQ2NTVmNDFhNjc1MDk=
|
6
|
+
metadata.gz: 3d38423aa6f80026a4dee623087b25679a385db5145ba4d0eebd5437fc66aa5551c698a0fe916a174bcbd85be599031443c374370cd086b92feed91b007a8c12
|
7
|
+
data.tar.gz: 5928eddd4c767222a2935ba4f35796e04d688893ee17d19fcc45b2a191965cbeea63ddbef5c540790fd876f8b2940d3105961ce7336b59a85e5f29c345d4b5d4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [1.0.1](https://github.com/puppetlabs/in-parallel/tree/1.0.1) (2023-08-24)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/puppetlabs/in-parallel/compare/1.0.0...1.0.1)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Bump activesupport from 7.0.4.3 to 7.0.7.2 [\#23](https://github.com/puppetlabs/in-parallel/pull/23) ([dependabot[bot]](https://github.com/apps/dependabot))
|
10
|
+
|
11
|
+
## [1.0.0](https://github.com/puppetlabs/in-parallel/tree/1.0.0) (2023-03-15)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/puppetlabs/in-parallel/compare/0.1.17...1.0.0)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- \(RE-15226\) Update codeowners and add standard workflows [\#20](https://github.com/puppetlabs/in-parallel/pull/20) ([yachub](https://github.com/yachub))
|
18
|
+
- \(maint\) update exists? -\> exist? for ruby 3.2 compatibility [\#19](https://github.com/puppetlabs/in-parallel/pull/19) ([tvpartytonight](https://github.com/tvpartytonight))
|
19
|
+
|
20
|
+
## [0.1.17](https://github.com/puppetlabs/in-parallel/tree/0.1.17) (2017-02-07)
|
21
|
+
|
22
|
+
[Full Changelog](https://github.com/puppetlabs/in-parallel/compare/0.1.16...0.1.17)
|
23
|
+
|
24
|
+
**Merged pull requests:**
|
25
|
+
|
26
|
+
- \(maint\) Properly handle non-parallel enumerables [\#17](https://github.com/puppetlabs/in-parallel/pull/17) ([nicklewis](https://github.com/nicklewis))
|
27
|
+
|
28
|
+
## [0.1.16](https://github.com/puppetlabs/in-parallel/tree/0.1.16) (2017-02-06)
|
29
|
+
|
30
|
+
[Full Changelog](https://github.com/puppetlabs/in-parallel/compare/0.1.15...0.1.16)
|
31
|
+
|
32
|
+
## [0.1.15](https://github.com/puppetlabs/in-parallel/tree/0.1.15) (2017-02-03)
|
33
|
+
|
34
|
+
[Full Changelog](https://github.com/puppetlabs/in-parallel/compare/0.1.14...0.1.15)
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- \(maint\) Avoid deadlock with large results [\#16](https://github.com/puppetlabs/in-parallel/pull/16) ([nicklewis](https://github.com/nicklewis))
|
39
|
+
- \(maint\) Revert name change of in\_parallel.rb [\#15](https://github.com/puppetlabs/in-parallel/pull/15) ([samwoods1](https://github.com/samwoods1))
|
40
|
+
|
41
|
+
## [0.1.14](https://github.com/puppetlabs/in-parallel/tree/0.1.14) (2016-08-08)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/puppetlabs/in-parallel/compare/0.1.13...0.1.14)
|
44
|
+
|
45
|
+
**Merged pull requests:**
|
46
|
+
|
47
|
+
- \(maint\) Consistent naming of in-parallel [\#14](https://github.com/puppetlabs/in-parallel/pull/14) ([samwoods1](https://github.com/samwoods1))
|
48
|
+
|
49
|
+
# experimental_in-parallel_bump_and_tag_master - History
|
50
|
+
## Tags
|
51
|
+
* [LATEST - 6 Feb, 2017 (8e97ff25)](#LATEST)
|
52
|
+
* [0.1.16 - 6 Feb, 2017 (0d5030c3)](#0.1.16)
|
53
|
+
* [0.1.15 - 3 Feb, 2017 (ff16929c)](#0.1.15)
|
54
|
+
* [0.1.14 - 8 Aug, 2016 (ce331dbd)](#0.1.14)
|
55
|
+
* [0.1.13 - 8 Aug, 2016 (26d19934)](#0.1.13)
|
56
|
+
|
57
|
+
## Details
|
58
|
+
### <a name = "LATEST">LATEST - 6 Feb, 2017 (8e97ff25)
|
59
|
+
|
60
|
+
* (GEM) update in-parallel version to 0.1.17 (8e97ff25)
|
61
|
+
|
62
|
+
* Merge pull request #17 from nicklewis/handle-non-parallel-enumerables (dca0b0a5)
|
63
|
+
|
64
|
+
|
65
|
+
```
|
66
|
+
Merge pull request #17 from nicklewis/handle-non-parallel-enumerables
|
67
|
+
|
68
|
+
(maint) Properly handle non-parallel enumerables
|
69
|
+
```
|
70
|
+
* (maint) Properly handle non-parallel enumerables (b041b864)
|
71
|
+
|
72
|
+
|
73
|
+
```
|
74
|
+
(maint) Properly handle non-parallel enumerables
|
75
|
+
|
76
|
+
For Enumerables containing 0 or 1 items, the #each_in_parallel method
|
77
|
+
was improperly calling the block without an argument, then calling it
|
78
|
+
again properly but not returning the result of the block.
|
79
|
+
|
80
|
+
The #each method returns the Enumerable that was it was called on,
|
81
|
+
rather than the value of the block. This needs to be #map instead, to
|
82
|
+
actually return an array of the one or zero values. The tests weren't
|
83
|
+
catching this because they were effectively passing `identity` as the
|
84
|
+
block, nullifying the distinction between #each and #map.
|
85
|
+
```
|
86
|
+
### <a name = "0.1.16">0.1.16 - 6 Feb, 2017 (0d5030c3)
|
87
|
+
|
88
|
+
* (HISTORY) update in-parallel history for gem release 0.1.16 (0d5030c3)
|
89
|
+
|
90
|
+
* (GEM) update in-parallel version to 0.1.16 (27b497ea)
|
91
|
+
|
92
|
+
### <a name = "0.1.15">0.1.15 - 3 Feb, 2017 (ff16929c)
|
93
|
+
|
94
|
+
* (HISTORY) update in-parallel history for gem release 0.1.15 (ff16929c)
|
95
|
+
|
96
|
+
* (GEM) update in-parallel version to 0.1.15 (206a62fe)
|
97
|
+
|
98
|
+
* Merge pull request #16 from nicklewis/support-large-results (4d644d88)
|
99
|
+
|
100
|
+
|
101
|
+
```
|
102
|
+
Merge pull request #16 from nicklewis/support-large-results
|
103
|
+
|
104
|
+
(maint) Avoid deadlock with large results
|
105
|
+
```
|
106
|
+
* (maint) Avoid deadlock with large results (a5a9c174)
|
107
|
+
|
108
|
+
|
109
|
+
```
|
110
|
+
(maint) Avoid deadlock with large results
|
111
|
+
|
112
|
+
Previously, if the result of a process was larger than the IO buffer
|
113
|
+
size (commonly 64k), execution would deadlock until the timeout.
|
114
|
+
|
115
|
+
In this scenario, the writer would fill the buffer and block until the
|
116
|
+
reader had cleared the buffer by reading. However, the reader will only
|
117
|
+
try to read once (to get the whole result) and will only attempt to read
|
118
|
+
after the child process has exited. This causes a deadlock, as the child
|
119
|
+
can't exit because it can't finish writing, but the the reader won't
|
120
|
+
read because the child hasn't exited.
|
121
|
+
|
122
|
+
This commit fixes the watcher loop to instead IO.select() from the
|
123
|
+
available result readers and read a partial result into a buffer whenever it's
|
124
|
+
available. This ensures that the writer will never remain blocked by a
|
125
|
+
full buffer. The reader now uses IO#eof? to determine whether the child
|
126
|
+
process has exited, at which point it will process the whole result as
|
127
|
+
before.
|
128
|
+
```
|
129
|
+
* Merge pull request #15 from samwoods1/add_jjb_pipelines (72d32635)
|
130
|
+
|
131
|
+
|
132
|
+
```
|
133
|
+
Merge pull request #15 from samwoods1/add_jjb_pipelines
|
134
|
+
|
135
|
+
(maint) Revert name change of in_parallel.rb
|
136
|
+
```
|
137
|
+
* (maint) Revert name change of in_parallel.rb (327c8fd5)
|
138
|
+
|
139
|
+
### <a name = "0.1.14">0.1.14 - 8 Aug, 2016 (ce331dbd)
|
140
|
+
|
141
|
+
* (HISTORY) update in-parallel history for gem release 0.1.14 (ce331dbd)
|
142
|
+
|
143
|
+
* (GEM) update in-parallel version to 0.1.14 (d026c624)
|
144
|
+
|
145
|
+
* Merge pull request #14 from samwoods1/add_jjb_pipelines (269bc350)
|
146
|
+
|
147
|
+
|
148
|
+
```
|
149
|
+
Merge pull request #14 from samwoods1/add_jjb_pipelines
|
150
|
+
|
151
|
+
(maint) Consistent naming of in-parallel
|
152
|
+
```
|
153
|
+
* (maint) Consistent naming of in-parallel (6fbb442d)
|
154
|
+
|
155
|
+
### <a name = "0.1.13">0.1.13 - 8 Aug, 2016 (26d19934)
|
156
|
+
|
157
|
+
* Initial release.
|
158
|
+
|
159
|
+
|
160
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/CODEOWNERS
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# This will cause RE to be assigned review of any opened PRs against
|
2
|
+
# the branches containing this file.
|
3
|
+
# See https://help.github.com/en/articles/about-code-owners for info on how to
|
4
|
+
# take ownership of parts of the code base that should be reviewed by another
|
5
|
+
# team.
|
6
|
+
|
7
|
+
# RE will be the default owners for everything in the repo.
|
8
|
+
* @puppetlabs/release-engineering
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
in-parallel (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (7.0.7.2)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 1.6, < 2)
|
12
|
+
minitest (>= 5.1)
|
13
|
+
tzinfo (~> 2.0)
|
14
|
+
concurrent-ruby (1.2.2)
|
15
|
+
diff-lcs (1.5.0)
|
16
|
+
docile (1.4.0)
|
17
|
+
i18n (1.14.1)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
iniparser (1.0.1)
|
20
|
+
kramdown (2.4.0)
|
21
|
+
rexml
|
22
|
+
logutils (0.6.1)
|
23
|
+
markdown (0.4.0)
|
24
|
+
kramdown (>= 0.13.7)
|
25
|
+
props (>= 0.2.0)
|
26
|
+
textutils (>= 0.2.0)
|
27
|
+
minitest (5.19.0)
|
28
|
+
props (1.2.0)
|
29
|
+
iniparser (>= 0.1.0)
|
30
|
+
rake (13.0.6)
|
31
|
+
rexml (3.2.5)
|
32
|
+
rspec (3.12.0)
|
33
|
+
rspec-core (~> 3.12.0)
|
34
|
+
rspec-expectations (~> 3.12.0)
|
35
|
+
rspec-mocks (~> 3.12.0)
|
36
|
+
rspec-core (3.12.1)
|
37
|
+
rspec-support (~> 3.12.0)
|
38
|
+
rspec-expectations (3.12.2)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.12.0)
|
41
|
+
rspec-mocks (3.12.4)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.12.0)
|
44
|
+
rspec-support (3.12.0)
|
45
|
+
rubyzip (2.3.2)
|
46
|
+
simplecov (0.22.0)
|
47
|
+
docile (~> 1.1)
|
48
|
+
simplecov-html (~> 0.11)
|
49
|
+
simplecov_json_formatter (~> 0.1)
|
50
|
+
simplecov-html (0.12.3)
|
51
|
+
simplecov_json_formatter (0.1.4)
|
52
|
+
textutils (1.4.0)
|
53
|
+
activesupport
|
54
|
+
logutils (>= 0.6.1)
|
55
|
+
props (>= 1.1.2)
|
56
|
+
rubyzip (>= 1.0.0)
|
57
|
+
tzinfo (2.0.6)
|
58
|
+
concurrent-ruby (~> 1.0)
|
59
|
+
webrick (1.7.0)
|
60
|
+
yard (0.9.28)
|
61
|
+
webrick (~> 1.7.0)
|
62
|
+
|
63
|
+
PLATFORMS
|
64
|
+
aarch64-linux
|
65
|
+
x86_64-linux
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
in-parallel!
|
69
|
+
markdown (~> 0)
|
70
|
+
rake (>= 0.9.0)
|
71
|
+
rspec (~> 3.1)
|
72
|
+
simplecov
|
73
|
+
yard (~> 0)
|
74
|
+
|
75
|
+
BUNDLED WITH
|
76
|
+
2.4.8
|
data/README.md
CHANGED
@@ -1,15 +1,31 @@
|
|
1
|
+
# in-parallel
|
2
|
+
|
3
|
+
- [in-parallel](#in-parallel)
|
4
|
+
- [Use Cases](#use-cases)
|
5
|
+
- [Install](#install)
|
6
|
+
- [Usage](#usage)
|
7
|
+
- [Methods](#methods)
|
8
|
+
- [run\_in\_parallel(timeout=nil, kill\_all\_on\_error = false, \&block)](#run_in_paralleltimeoutnil-kill_all_on_error--false-block)
|
9
|
+
- [Enumerable.each\_in\_parallel(identifier=nil, timeout=(InParallel::InParallelExecutor.timeout), kill\_all\_on\_error = false, \&block)](#enumerableeach_in_parallelidentifiernil-timeoutinparallelinparallelexecutortimeout-kill_all_on_error--false-block)
|
10
|
+
- [run\_in\_background(ignore\_results = true, \&block)](#run_in_backgroundignore_results--true-block)
|
11
|
+
- [wait\_for\_processes(timeout=nil, kill\_all\_on\_error = false)](#wait_for_processestimeoutnil-kill_all_on_error--false)
|
12
|
+
- [Global Options](#global-options)
|
13
|
+
- [Releasing](#releasing)
|
1
14
|
|
2
15
|
A lightweight Ruby library with very simple syntax, making use of Process.fork to execute code in parallel.
|
3
16
|
|
4
|
-
|
17
|
+
## Use Cases
|
18
|
+
|
5
19
|
Many other Ruby libraries that simplify parallel execution support one primary use case - crunching through a large queue of small, similar tasks as quickly and efficiently as possible. This library primarily supports the use case of executing a few larger and unrelated tasks in parallel, automatically managing the stdout and passing return values back to the main process. This library was created to be used by Puppet's Beaker test framework to enable parallel execution of some of the framework's tasks, and allow users to execute code in parallel within their tests.
|
6
20
|
|
7
21
|
If you are looking for something that excels at executing a large queue of tasks in parallel as efficiently as possible, you should take a look at the [parallel](https://github.com/grosser/parallel) project.
|
8
22
|
|
9
|
-
|
23
|
+
## Install
|
24
|
+
|
10
25
|
```gem install in-parallel```
|
11
26
|
|
12
|
-
|
27
|
+
## Usage
|
28
|
+
|
13
29
|
```include InParallel``` to use as a mix-in
|
14
30
|
|
15
31
|
The methods below allow you to fork processes to execute multiple methods or blocks within an enumerable in parallel. They all have this common behavior:
|
@@ -24,7 +40,9 @@ The methods below allow you to fork processes to execute multiple methods or blo
|
|
24
40
|
1. Will timeout (stop execution and raise an exception) based on a global timeout value, or timeout parameter.
|
25
41
|
|
26
42
|
## Methods
|
43
|
+
|
27
44
|
### run_in_parallel(timeout=nil, kill_all_on_error = false, &block)
|
45
|
+
|
28
46
|
1. Each method in a block will be executed in parallel (unless the method is defined in Kernel or BaseObject).
|
29
47
|
1. Any methods further down the stack won't be affected, only the ones directly within the block.
|
30
48
|
1. Waits for each process in realtime and logs immediately upon completion of each process
|
@@ -53,8 +71,10 @@ The methods below allow you to fork processes to execute multiple methods or blo
|
|
53
71
|
|
54
72
|
puts "#{@result_1}, #{@result_2[:foo]}"
|
55
73
|
```
|
74
|
+
|
56
75
|
stdout:
|
57
|
-
|
76
|
+
|
77
|
+
```shell
|
58
78
|
Forked process for 'method_with_param' - PID = '49398'
|
59
79
|
Forked process for 'method_without_param' - PID = '49399'
|
60
80
|
|
@@ -67,7 +87,9 @@ hello world
|
|
67
87
|
------ Completed output for method_without_param - 49399
|
68
88
|
hello world, bar
|
69
89
|
```
|
90
|
+
|
70
91
|
### Enumerable.each_in_parallel(identifier=nil, timeout=(InParallel::InParallelExecutor.timeout), kill_all_on_error = false, &block)
|
92
|
+
|
71
93
|
1. This is very similar to other solutions, except that it directly extends the Enumerable class with an each_in_parallel method, giving you the ability to pretty simply spawn a process for any item in an array or map.
|
72
94
|
1. Identifies the block location (or caller location if the block does not have a source_location) in the console log to make it clear which block is being executed
|
73
95
|
1. Identifier param is only for logging, otherwise it will use the block source location.
|
@@ -77,6 +99,7 @@ hello world, bar
|
|
77
99
|
```
|
78
100
|
|
79
101
|
### run_in_background(ignore_results = true, &block)
|
102
|
+
|
80
103
|
1. This does basically the same thing as run_in_parallel, except it does not wait for execution of all processes to complete, it returns immediately.
|
81
104
|
1. You can optionally ignore results completely (default) or delay evaluating the results until later
|
82
105
|
1. You can run multiple blocks in the background and then at some later point evaluate all of the results
|
@@ -94,11 +117,12 @@ hello world, bar
|
|
94
117
|
run_in_background { create_file_with_delay(TMP_FILE) }
|
95
118
|
|
96
119
|
# Should not exist immediately upon block completion
|
97
|
-
puts(File.
|
120
|
+
puts(File.exist?(TMP_FILE)) # false
|
98
121
|
sleep(3)
|
99
122
|
# Should exist once the delay from create_file_with_delay is done
|
100
|
-
puts(File.
|
123
|
+
puts(File.exist?(TMP_FILE)) # true
|
101
124
|
```
|
125
|
+
|
102
126
|
```ruby
|
103
127
|
# Example 2 - delay results
|
104
128
|
run_in_background(false) { @result = create_file_with_delay(TMP_FILE) }
|
@@ -118,13 +142,16 @@ hello world, bar
|
|
118
142
|
```
|
119
143
|
|
120
144
|
### wait_for_processes(timeout=nil, kill_all_on_error = false)
|
145
|
+
|
121
146
|
1. Used only after run_in_background with ignore_results=false
|
122
147
|
1. Optional args for timeout and kill_all_on_error
|
123
148
|
1. See run_in_background for examples
|
124
149
|
|
125
150
|
## Global Options
|
151
|
+
|
126
152
|
You can get or set the following values to set global defaults. These defaults can also be specified per execution by supplying the values as parameters to the parallel methods.
|
127
|
-
|
153
|
+
|
154
|
+
```ruby
|
128
155
|
# How many seconds to wait between logging a 'Waiting for child processes.' message. Defaults to 30 seconds
|
129
156
|
parallel_signal_interval
|
130
157
|
|
@@ -137,3 +164,11 @@ You can get or set the following values to set global defaults. These defaults
|
|
137
164
|
@logger.log_level
|
138
165
|
```
|
139
166
|
|
167
|
+
## Releasing
|
168
|
+
|
169
|
+
Follow these steps to publish a new GitHub release, and build and push the gem to <https://rubygems.org>.
|
170
|
+
|
171
|
+
1. Bump the "VERSION" in lib/in-parallel/version.rb appropriately based on changes in CHANGELOG.md since the last release.
|
172
|
+
2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`.
|
173
|
+
3. Commit and push changes to a new branch, then open a pull request against main and be sure to add the "maintenance" label.
|
174
|
+
4. After the pull request is approved and merged, then navigate to Actions --> Release Gem --> run workflow --> Branch: main --> Run workflow.
|
data/lib/in-parallel/version.rb
CHANGED
data/lib/in_parallel.rb
CHANGED
@@ -152,7 +152,7 @@ module InParallel
|
|
152
152
|
end
|
153
153
|
results_map[process_info[:index]] = { process_info[:tmp_result] => marshalled_result }
|
154
154
|
ensure
|
155
|
-
File.delete(process_info[:std_out]) if File.
|
155
|
+
File.delete(process_info[:std_out]) if File.exist?(process_info[:std_out])
|
156
156
|
# close the read end pipe
|
157
157
|
process_info[:result].close unless process_info[:result].closed?
|
158
158
|
@@process_infos.delete(process_info)
|
@@ -185,7 +185,7 @@ module InParallel
|
|
185
185
|
ret_val = nil
|
186
186
|
# Communicate the return value of the method or block
|
187
187
|
read_result, write_result = IO.pipe
|
188
|
-
Dir.mkdir('tmp') unless Dir.
|
188
|
+
Dir.mkdir('tmp') unless Dir.exist? 'tmp'
|
189
189
|
pid = fork do
|
190
190
|
stdout_file = File.new("tmp/pp_#{Process.pid}", 'w')
|
191
191
|
exit_status = 0
|
data/spec/in-paralell_spec.rb
CHANGED
@@ -75,7 +75,7 @@ end
|
|
75
75
|
#Tests
|
76
76
|
describe '.run_in_parallel' do
|
77
77
|
before do
|
78
|
-
File.delete(TMP_FILE) if File.
|
78
|
+
File.delete(TMP_FILE) if File.exist?(TMP_FILE)
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should run methods in another process' do
|
@@ -169,7 +169,7 @@ end
|
|
169
169
|
|
170
170
|
describe '.run_in_background' do
|
171
171
|
before do
|
172
|
-
File.delete(TMP_FILE) if File.
|
172
|
+
File.delete(TMP_FILE) if File.exist?(TMP_FILE)
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'should run in the background' do
|
@@ -177,11 +177,11 @@ describe '.run_in_background' do
|
|
177
177
|
|
178
178
|
start = Time.now
|
179
179
|
# Should not exist immediately upon block completion
|
180
|
-
expect(File.
|
180
|
+
expect(File.exist? TMP_FILE).to eq false
|
181
181
|
# Give this some time to complete since it takes longer on the vmpooler vms
|
182
182
|
file_exists = false
|
183
183
|
while Time.now < start + 10 do
|
184
|
-
if File.
|
184
|
+
if File.exist? TMP_FILE
|
185
185
|
file_exists = true
|
186
186
|
break
|
187
187
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: in-parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- samwoods1
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Many other Ruby libraries that simplify parallel execution support one
|
14
14
|
primary use case - crunching through a large queue of small, similar tasks as quickly
|
@@ -24,11 +24,13 @@ executables: []
|
|
24
24
|
extensions: []
|
25
25
|
extra_rdoc_files: []
|
26
26
|
files:
|
27
|
+
- CHANGELOG.md
|
28
|
+
- CODEOWNERS
|
27
29
|
- CONTRIBUTING.md
|
28
30
|
- Gemfile
|
31
|
+
- Gemfile.lock
|
29
32
|
- HISTORY.md
|
30
33
|
- LICENSE
|
31
|
-
- MAINTAINERS.md
|
32
34
|
- README.md
|
33
35
|
- Rakefile
|
34
36
|
- lib/in-parallel/version.rb
|
@@ -46,17 +48,16 @@ require_paths:
|
|
46
48
|
- lib
|
47
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
50
|
requirements:
|
49
|
-
- -
|
51
|
+
- - ">="
|
50
52
|
- !ruby/object:Gem::Version
|
51
53
|
version: '0'
|
52
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
55
|
requirements:
|
54
|
-
- -
|
56
|
+
- - ">="
|
55
57
|
- !ruby/object:Gem::Version
|
56
58
|
version: '0'
|
57
59
|
requirements: []
|
58
|
-
|
59
|
-
rubygems_version: 2.4.6
|
60
|
+
rubygems_version: 3.4.10
|
60
61
|
signing_key:
|
61
62
|
specification_version: 4
|
62
63
|
summary: A lightweight library to execute a handful of tasks in parallel with simple
|
data/MAINTAINERS.md
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# Reviewers/Maintainers For in-parallel
|
2
|
-
|
3
|
-
in-parallel is maintained by Puppet's Quality Assurance (QA) Team. These people
|
4
|
-
will be reviewing & merging PRs to the project.
|
5
|
-
|
6
|
-
| Name | Github | Email |
|
7
|
-
|:--------------:|:---------------------------------------------------:|:---------------------------:|
|
8
|
-
| Sam Woods | [samwoods1](https://github.com/samwoods1) | <sam.woods@puppet.com> |
|
9
|
-
| Zach Reichert | [zreichert](https://github.com/zreichert) | <zach.reichert@puppet.com> |
|