timeout-interrupt 0.2.2 → 0.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.
- data/VERSION +1 -1
- data/lib/timeout_interrupt.rb +11 -7
- data/test/test_ruby-timeout-interrupt.rb +7 -0
- data/timeout-interrupt.gemspec +2 -2
- metadata +19 -19
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/timeout_interrupt.rb
CHANGED
@@ -74,9 +74,10 @@ module TimeoutInterruptSingleton
|
|
74
74
|
|
75
75
|
# Creates a timeout and calls your block, which has to finish before timeout occurs.
|
76
76
|
#
|
77
|
+
# @param seconds [0] No timeout, so block can take any time.
|
77
78
|
# @param seconds [Integer] In `seconds` Seconds, it should raise a timeout, if not finished.
|
78
|
-
# @param seconds [nil]
|
79
|
-
#
|
79
|
+
# @param seconds [nil] If also no block given, everything will be ignored and
|
80
|
+
# it will call {setup} for checking and preparing next known timeout.
|
80
81
|
# @param exception [Exception] which will be raised if timed out.
|
81
82
|
# @param exception [nil] `TimeoutInterrupt::Error` will be used to raise.
|
82
83
|
# @param block [Proc] Will be called and should finish its work before it timed out.
|
@@ -102,6 +103,7 @@ module TimeoutInterruptSingleton
|
|
102
103
|
# @see TimeoutInterrupt#timeout
|
103
104
|
# @raise exception
|
104
105
|
def timeout seconds = nil, exception = nil, &block
|
106
|
+
return yield( seconds) if seconds.nil? || 0 == seconds if block_given?
|
105
107
|
return setup if seconds.nil?
|
106
108
|
seconds = seconds.to_i
|
107
109
|
exception ||= TimeoutInterrupt::Error
|
@@ -117,7 +119,7 @@ module TimeoutInterruptSingleton
|
|
117
119
|
begin
|
118
120
|
self.timeouts[key] = [at, bt, exception]
|
119
121
|
setup
|
120
|
-
yield
|
122
|
+
yield seconds
|
121
123
|
ensure
|
122
124
|
self.timeouts.delete key
|
123
125
|
setup
|
@@ -140,9 +142,10 @@ module TimeoutInterrupt
|
|
140
142
|
|
141
143
|
# Creates a timeout and calls your block, which has to finish before timeout occurs.
|
142
144
|
#
|
145
|
+
# @param seconds [0] No timeout, so block can take any time.
|
143
146
|
# @param seconds [Integer] In `seconds` Seconds, it should raise a timeout, if not finished.
|
144
|
-
# @param seconds [nil]
|
145
|
-
#
|
147
|
+
# @param seconds [nil] If also no block given, everything will be ignored and
|
148
|
+
# it will call {setup} for checking and preparing next known timeout.
|
146
149
|
# @param exception [Exception] which will be raised if timed out.
|
147
150
|
# @param exception [nil] `TimeoutInterrupt::Error` will be used to raise.
|
148
151
|
# @param block [Proc] Will be called and should finish its work before it timed out.
|
@@ -173,9 +176,10 @@ module TimeoutInterrupt
|
|
173
176
|
|
174
177
|
# Creates a timeout and calls your block, which has to finish before timeout occurs.
|
175
178
|
#
|
179
|
+
# @param seconds [0] No timeout, so block can take any time.
|
176
180
|
# @param seconds [Integer] In `seconds` Seconds, it should raise a timeout, if not finished.
|
177
|
-
# @param seconds [nil]
|
178
|
-
#
|
181
|
+
# @param seconds [nil] If also no block given, everything will be ignored and
|
182
|
+
# it will call {setup} for checking and preparing next known timeout.
|
179
183
|
# @param exception [Exception] which will be raised if timed out.
|
180
184
|
# @param exception [nil] `TimeoutInterrupt::Error` will be used to raise.
|
181
185
|
# @param block [Proc] Will be called and should finish its work before it timed out.
|
@@ -152,4 +152,11 @@ class TestRubyTimeoutInterrupt < Test::Unit::TestCase
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
155
|
+
|
156
|
+
should "not timeout, if timeout is 0" do
|
157
|
+
assert_nothing_raised TimeoutInterrupt::Error, "Unexpected Timed out." do
|
158
|
+
# should never timeout (we can not wait infinity seconds, so only 5)
|
159
|
+
TimeoutInterrupt.timeout( 0) { sleep 5 }
|
160
|
+
end
|
161
|
+
end
|
155
162
|
end
|
data/timeout-interrupt.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "timeout-interrupt"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Denis Knauf"]
|
12
|
-
s.date = "2013-03-
|
12
|
+
s.date = "2013-03-14"
|
13
13
|
s.description = "Timeout-lib, which interrupts everything, also systemcalls. It uses libc-alarm."
|
14
14
|
s.email = "Denis.Knauf@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timeout-interrupt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi-libc
|
16
|
-
requirement: &
|
16
|
+
requirement: &75104850 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *75104850
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &75104590 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *75104590
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &75104250 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *75104250
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: redcarpet
|
49
|
-
requirement: &
|
49
|
+
requirement: &75103900 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *75103900
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &75103530 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *75103530
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &75103120 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *75103120
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
requirement: &
|
82
|
+
requirement: &75102780 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *75102780
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: simplecov
|
93
|
-
requirement: &
|
93
|
+
requirement: &75102430 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *75102430
|
102
102
|
description: Timeout-lib, which interrupts everything, also systemcalls. It uses libc-alarm.
|
103
103
|
email: Denis.Knauf@gmail.com
|
104
104
|
executables: []
|
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
segments:
|
135
135
|
- 0
|
136
|
-
hash: -
|
136
|
+
hash: -714401361
|
137
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|