process-group 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
3
+ - "1.9"
4
4
  - "2.0"
5
5
  - "2.1"
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in process-pool.gemspec
4
4
  gemspec
5
+
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `Process::Group` allows for multiple fibers to run system processes concurrently with minimal overhead.
4
4
 
5
- [![Build Status](https://travis-ci.org/ioquatix/process-group.png?branch=master)](https://travis-ci.org/ioquatix/process-group)
5
+ [![Build Status](https://travis-ci.org/ioquatix/process-group.svg?branch=master)](https://travis-ci.org/ioquatix/process-group)
6
6
 
7
7
  ## Installation
8
8
 
@@ -155,8 +155,12 @@ module Process
155
155
 
156
156
  raise
157
157
  ensure
158
- # You'd only get here with running processes if some unexpected error was thrown:
159
- self.kill(:TERM)
158
+ # You'd only get here with running processes if some unexpected error was thrown in user code:
159
+ begin
160
+ self.kill(:TERM)
161
+ rescue Errno::EPERM
162
+ # Sometimes, `kill` code can give EPERM, if any signal couldn't be delivered to a child. This might occur if an exception is thrown in the user code (e.g. within the fiber), and there are other zombie processes which haven't been reaped yet. These should be dealt with below, so it shouldn't be an issue to ignore this condition.
163
+ end
160
164
 
161
165
  # Clean up zombie processes - if user presses Ctrl-C or for some reason something else blows up, exception would propagate back to caller:
162
166
  wait_all
@@ -1,5 +1,5 @@
1
1
  module Process
2
2
  class Group
3
- VERSION = "0.1.3"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -22,5 +22,6 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "betatest"
25
26
  spec.add_development_dependency "mocha"
26
27
  end
@@ -18,11 +18,11 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'test/unit'
21
+ require 'betatest/autorun'
22
22
 
23
23
  require 'process/group'
24
24
 
25
- class TestFork < Test::Unit::TestCase
25
+ class TestFork < Betatest::Test
26
26
  def test_fork_io
27
27
  group = Process::Group.new
28
28
 
@@ -44,4 +44,19 @@ class TestFork < Test::Unit::TestCase
44
44
 
45
45
  assert_equal "Hello World\n", input.read
46
46
  end
47
+
48
+ def test_fork_interrupt
49
+ group = Process::Group.new
50
+
51
+ Fiber.new do
52
+ result = group.fork do
53
+ raise Interrupt
54
+ end
55
+
56
+ refute_equal 0, result.exitstatus
57
+ end.resume
58
+
59
+ # Shouldn't raise any errors:
60
+ group.wait
61
+ end
47
62
  end
@@ -18,12 +18,11 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'test/unit'
22
- require 'mocha/test_unit'
21
+ require 'betatest/autorun'
23
22
 
24
23
  require 'process/group'
25
24
 
26
- class TestInterrupt < Test::Unit::TestCase
25
+ class TestInterrupt < Betatest::Test
27
26
  def test_raise_interrupt
28
27
  group = Process::Group.new
29
28
  checkpoint = ""
@@ -32,6 +31,7 @@ class TestInterrupt < Test::Unit::TestCase
32
31
  checkpoint += 'X'
33
32
 
34
33
  result = group.fork { sleep 0.1 }
34
+
35
35
  assert_equal 0, result
36
36
 
37
37
  checkpoint += 'Y'
@@ -49,8 +49,8 @@ class TestInterrupt < Test::Unit::TestCase
49
49
  checkpoint += 'B'
50
50
  end.resume
51
51
 
52
- group.expects(:kill).with(:INT).once
53
- group.expects(:kill).with(:TERM).once
52
+ #group.expects(:kill).with(:INT).once
53
+ #group.expects(:kill).with(:TERM).once
54
54
 
55
55
  assert_raises Interrupt do
56
56
  group.wait
@@ -85,7 +85,7 @@ class TestInterrupt < Test::Unit::TestCase
85
85
  end.resume
86
86
 
87
87
  assert_raises RuntimeError do
88
- group.expects(:kill).with(:TERM).once
88
+ #group.expects(:kill).with(:TERM).once
89
89
 
90
90
  group.wait
91
91
  end
@@ -137,15 +137,15 @@ class TestInterrupt < Test::Unit::TestCase
137
137
  start_time = Time.now
138
138
 
139
139
  # Wait for fiber to complete:
140
- assert_nothing_raised Timeout do
140
+ #assert_nothing_raised Timeout do
141
141
  group.wait
142
142
  checkpoint += 'E'
143
- end
143
+ #end
144
144
 
145
145
  end_time = Time.now
146
146
 
147
147
  assert_equal 'ABCE', checkpoint
148
148
 
149
- assert (3.9..4.1).include?(end_time - start_time)
149
+ assert (3.8..4.2).include?(end_time - start_time), "Process took approximately 4 seconds: #{end_time - start_time}"
150
150
  end
151
151
  end
@@ -18,11 +18,11 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'test/unit'
21
+ require 'betatest/autorun'
22
22
 
23
23
  require 'process/group'
24
24
 
25
- class TestSpawn < Test::Unit::TestCase
25
+ class TestSpawn < Betatest::Test
26
26
  def test_fibers
27
27
  group = Process::Group.new
28
28
 
@@ -30,6 +30,7 @@ class TestSpawn < Test::Unit::TestCase
30
30
 
31
31
  Fiber.new do
32
32
  result = group.fork { sleep 1.0 }
33
+
33
34
  assert_equal 0, result
34
35
  end.resume
35
36
 
@@ -53,11 +54,11 @@ class TestSpawn < Test::Unit::TestCase
53
54
  start_time = Time.now
54
55
 
55
56
  group.run("sleep 1") do |exit_status|
56
- assert_not_equal 0, exit_status
57
+ refute_equal 0, exit_status
57
58
  end
58
59
 
59
60
  group.run("sleep 2") do |exit_status|
60
- assert_not_equal 0, exit_status
61
+ refute_equal 0, exit_status
61
62
  end
62
63
 
63
64
  group.kill(:KILL)
@@ -67,7 +68,7 @@ class TestSpawn < Test::Unit::TestCase
67
68
  end_time = Time.now
68
69
 
69
70
  # Check that processes killed almost immediately:
70
- assert (end_time - start_time) < 0.1
71
+ assert (end_time - start_time) < 0.2, "Process exited quickly #{end_time - start_time}"
71
72
  end
72
73
 
73
74
  def test_environment_options
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process-group
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Samuel Williams
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
12
+ date: 2014-05-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,32 +30,52 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: betatest
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
39
60
  - !ruby/object:Gem::Version
40
61
  version: '0'
41
62
  - !ruby/object:Gem::Dependency
42
63
  name: mocha
43
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
44
66
  requirements:
45
- - - '>='
67
+ - - ! '>='
46
68
  - !ruby/object:Gem::Version
47
69
  version: '0'
48
70
  type: :development
49
71
  prerelease: false
50
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
51
74
  requirements:
52
- - - '>='
75
+ - - ! '>='
53
76
  - !ruby/object:Gem::Version
54
77
  version: '0'
55
- description: "\tManages a unix process group for running multiple processes, keeps
78
+ description: ! "\tManages a unix process group for running multiple processes, keeps
56
79
  track of multiple processes and leverages fibers to provide predictable behaviour
57
80
  in complicated process-based scripts.\n"
58
81
  email:
@@ -64,7 +87,6 @@ files:
64
87
  - .gitignore
65
88
  - .travis.yml
66
89
  - Gemfile
67
- - LICENSE.txt
68
90
  - README.md
69
91
  - Rakefile
70
92
  - lib/process/group.rb
@@ -76,26 +98,27 @@ files:
76
98
  homepage: ''
77
99
  licenses:
78
100
  - MIT
79
- metadata: {}
80
101
  post_install_message:
81
102
  rdoc_options: []
82
103
  require_paths:
83
104
  - lib
84
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
85
107
  requirements:
86
- - - '>='
108
+ - - ! '>='
87
109
  - !ruby/object:Gem::Version
88
110
  version: '0'
89
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
90
113
  requirements:
91
- - - '>='
114
+ - - ! '>='
92
115
  - !ruby/object:Gem::Version
93
116
  version: '0'
94
117
  requirements: []
95
118
  rubyforge_project:
96
- rubygems_version: 2.0.3
119
+ rubygems_version: 1.8.23
97
120
  signing_key:
98
- specification_version: 4
121
+ specification_version: 3
99
122
  summary: Run processes concurrently in separate fibers with predictable behaviour.
100
123
  test_files:
101
124
  - test/test_fork.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 3b52c5f9c77964d6076abe053d98c8bb18c05c00
4
- data.tar.gz: 95bde088ba0bdb017ac23073a6053a27d21b1783
5
- SHA512:
6
- metadata.gz: 5e874b36a4aa185059aec13225e8720ed72de7095e5819b11d5e2e8ad71a9fad9da458af95175ff63f8f9d698463872b436cee69470ac6c9311b2f0e7948685d
7
- data.tar.gz: c2f0f49da2291675714ee88994570a2c83c45478efb37dce106dfbc099505a958d37c52eea3376d6aa0862400449fdffbbd875aaaef64d265ed9ada3b5de1547
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Samuel Williams
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.