async 1.9.1 → 1.10.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/.editorconfig +1 -1
- data/README.md +1 -1
- data/lib/async/reactor.rb +4 -4
- data/lib/async/version.rb +1 -1
- data/spec/async/task_spec.rb +10 -6
- 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: fc6f62aa8e36dcfa1864f1b34d6f81b220583b511b1e81843cca29ba57669160
|
4
|
+
data.tar.gz: 0fb3bdc83efe1d7ebb06594d7b85c481d8934e1ba0a73a2858a6e1b772ef2971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b9881a10f81214fbea511eb8d4c7fd1d96af8e92dfebb6452604fe4d6ae35dfa667fbace3c600c25ecdbccb6cfdba6dacbc7bba058051a7e7c7d4de4ceb2941
|
7
|
+
data.tar.gz: 3db5a1c721168949e2aef7dae62aab8efc48e960124e894c112245a7174ccea0487e47fb1794750c5434ed192e357cbd19b705b9ebd72992a4b03801754e254d
|
data/.editorconfig
CHANGED
data/README.md
CHANGED
@@ -110,7 +110,7 @@ As tasks run synchronously until they yield back to the reactor, you can guarant
|
|
110
110
|
This library aims to support and is [tested against][travis] the following Ruby
|
111
111
|
versions:
|
112
112
|
|
113
|
-
* Ruby 2.
|
113
|
+
* Ruby 2.2+
|
114
114
|
* JRuby 9.1.6.0+
|
115
115
|
|
116
116
|
If something doesn't work on one of these versions, it's a bug.
|
data/lib/async/reactor.rb
CHANGED
@@ -28,7 +28,7 @@ require 'forwardable'
|
|
28
28
|
|
29
29
|
module Async
|
30
30
|
# Raised if a timeout occurs on a specific Fiber. Handled gracefully by {Task}.
|
31
|
-
class TimeoutError <
|
31
|
+
class TimeoutError < Exception
|
32
32
|
end
|
33
33
|
|
34
34
|
# An asynchronous, cooperatively scheduled event reactor.
|
@@ -230,13 +230,13 @@ module Async
|
|
230
230
|
# complete.
|
231
231
|
def timeout(duration)
|
232
232
|
backtrace = caller
|
233
|
-
|
233
|
+
fiber = Fiber.current
|
234
234
|
|
235
235
|
timer = self.after(duration) do
|
236
|
-
if
|
236
|
+
if fiber.alive?
|
237
237
|
error = TimeoutError.new("execution expired")
|
238
238
|
error.set_backtrace backtrace
|
239
|
-
|
239
|
+
fiber.resume error
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
data/lib/async/version.rb
CHANGED
data/spec/async/task_spec.rb
CHANGED
@@ -156,16 +156,20 @@ RSpec.describe Async::Task do
|
|
156
156
|
state = nil
|
157
157
|
|
158
158
|
task = reactor.async do |task|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
159
|
+
begin
|
160
|
+
task.timeout(0.01) do
|
161
|
+
state = :started
|
162
|
+
task.sleep(10)
|
163
|
+
state = :finished
|
164
|
+
end
|
165
|
+
rescue Async::TimeoutError
|
166
|
+
state = :timeout
|
167
|
+
end
|
164
168
|
end
|
165
169
|
|
166
170
|
reactor.run
|
167
171
|
|
168
|
-
expect(state).to be == :
|
172
|
+
expect(state).to be == :timeout
|
169
173
|
end
|
170
174
|
|
171
175
|
it "won't timeout if execution completes in time" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nio4r
|