async 2.6.4 → 2.7.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
- checksums.yaml.gz.sig +0 -0
- data/lib/async/node.rb +0 -4
- data/lib/async/scheduler.rb +40 -3
- data/lib/async/task.rb +1 -1
- data/lib/async/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53de22a28c0c092ca81a83cb13c3ffba282d837c3eaab45fac9c8b130e0483a7
|
4
|
+
data.tar.gz: 647c8709231ffd1c24d1e6d166978ffe5b7b0ed3da17054dd8c43f131a8b29f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b38fe4b6304d66e7911f392c15334a0e3fadd4751a593fbcfcc4aa31726d02d7482888f0d038568dee034647cba7453a50916aecb1d40111ee7a3d1d76c555ba
|
7
|
+
data.tar.gz: 4b48c52dc39f10835f36e84d25b45ab5b6d89f213c232fd8f791e0c1d318901eb1826a5c57fca8daa95b8ba32f6130e02f022986c40bdfc194aab8506b47a5bb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/node.rb
CHANGED
data/lib/async/scheduler.rb
CHANGED
@@ -165,29 +165,66 @@ module Async
|
|
165
165
|
::Resolv.getaddresses(hostname)
|
166
166
|
end
|
167
167
|
|
168
|
+
|
169
|
+
if IO.method_defined?(:timeout)
|
170
|
+
private def get_timeout(io)
|
171
|
+
io.timeout
|
172
|
+
end
|
173
|
+
else
|
174
|
+
private def get_timeout(io)
|
175
|
+
nil
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
168
179
|
# @asynchronous May be non-blocking..
|
169
180
|
def io_wait(io, events, timeout = nil)
|
170
181
|
fiber = Fiber.current
|
171
182
|
|
172
183
|
if timeout
|
184
|
+
# If an explicit timeout is specified, we expect that the user will handle it themselves:
|
173
185
|
timer = @timers.after(timeout) do
|
174
186
|
fiber.transfer
|
175
187
|
end
|
188
|
+
elsif timeout = get_timeout(io)
|
189
|
+
# Otherwise, if we default to the io's timeout, we raise an exception:
|
190
|
+
timer = @timers.after(timeout) do
|
191
|
+
fiber.raise(::IO::TimeoutError, "Timeout while waiting for IO to become ready!")
|
192
|
+
end
|
176
193
|
end
|
177
194
|
|
178
195
|
return @selector.io_wait(fiber, io, events)
|
179
196
|
ensure
|
180
197
|
timer&.cancel
|
181
198
|
end
|
182
|
-
|
199
|
+
|
183
200
|
if ::IO::Event::Support.buffer?
|
184
201
|
def io_read(io, buffer, length, offset = 0)
|
185
|
-
|
202
|
+
fiber = Fiber.current
|
203
|
+
|
204
|
+
if timeout = get_timeout(io)
|
205
|
+
timer = @timers.after(timeout) do
|
206
|
+
fiber.raise(::IO::TimeoutError, "execution expired")
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
@selector.io_read(fiber, io, buffer, length, offset)
|
211
|
+
ensure
|
212
|
+
timer&.cancel
|
186
213
|
end
|
187
214
|
|
188
215
|
if RUBY_ENGINE != "ruby" || RUBY_VERSION >= "3.3.0"
|
189
216
|
def io_write(io, buffer, length, offset = 0)
|
190
|
-
|
217
|
+
fiber = Fiber.current
|
218
|
+
|
219
|
+
if timeout = get_timeout(io)
|
220
|
+
timer = @timers.after(timeout) do
|
221
|
+
fiber.raise(::IO::TimeoutError, "execution expired")
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
@selector.io_write(fiber, io, buffer, length, offset)
|
226
|
+
ensure
|
227
|
+
timer&.cancel
|
191
228
|
end
|
192
229
|
end
|
193
230
|
end
|
data/lib/async/task.rb
CHANGED
@@ -175,7 +175,7 @@ module Async
|
|
175
175
|
return task
|
176
176
|
end
|
177
177
|
|
178
|
-
# Retrieve the current result of the task. Will cause the caller to wait until result is available. If the
|
178
|
+
# Retrieve the current result of the task. Will cause the caller to wait until result is available. If the task resulted in an unhandled error (derived from `StandardError`), this will be raised. If the task was stopped, this will return `nil`.
|
179
179
|
#
|
180
180
|
# Conceptually speaking, waiting on a task should return a result, and if it throws an exception, this is certainly an exceptional case that should represent a failure in your program, not an expected outcome. In other words, you should not design your programs to expect exceptions from `#wait` as a normal flow control, and prefer to catch known exceptions within the task itself and return a result that captures the intention of the failure, e.g. a `TimeoutError` might simply return `nil` or `false` to indicate that the operation did not generate a valid result (as a timeout was an expected outcome of the internal operation in this case).
|
181
181
|
#
|
data/lib/async/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -58,7 +58,7 @@ cert_chain:
|
|
58
58
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
59
59
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
60
60
|
-----END CERTIFICATE-----
|
61
|
-
date:
|
61
|
+
date: 2024-01-02 00:00:00.000000000 Z
|
62
62
|
dependencies:
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: console
|
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
266
|
- !ruby/object:Gem::Version
|
267
267
|
version: '0'
|
268
268
|
requirements: []
|
269
|
-
rubygems_version: 3.
|
269
|
+
rubygems_version: 3.4.22
|
270
270
|
signing_key:
|
271
271
|
specification_version: 4
|
272
272
|
summary: A concurrency framework for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|