async 2.15.3 → 2.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/scheduler.rb +3 -3
- data/lib/async/task.rb +7 -0
- data/lib/async/variable.rb +4 -5
- data/lib/async/version.rb +1 -1
- data/lib/kernel/async.rb +2 -0
- data/lib/kernel/sync.rb +2 -0
- data/readme.md +17 -9
- data/releases.md +24 -0
- data.tar.gz.sig +0 -0
- metadata +4 -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: cd3699fb686c1acc86c39923b81f946f30be577b19eedde83ccb18c156490bfa
|
4
|
+
data.tar.gz: 27f7af6e0106d94fc8d0a6da188d6c923bc9afce09a32fddad1258367f9d683c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3d03ffcf1b3f7f3d3a4d8f3285092e4a6a6367f91259fbc17aba628d2aa6c8dbbbdcae0093a129a4a7f942f9bcf805d29cfe4e0cd715627ec62098a0e91303
|
7
|
+
data.tar.gz: 65c681adf6715d125e270b323a39db62cf91efd22628884f48131b68f639ffdd5acc69402181b33f63104a2fb648135f327b2abce8a39d366024be0ca7c30665
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/scheduler.rb
CHANGED
@@ -241,7 +241,7 @@ module Async
|
|
241
241
|
elsif timeout = get_timeout(io)
|
242
242
|
# Otherwise, if we default to the io's timeout, we raise an exception:
|
243
243
|
timer = @timers.after(timeout) do
|
244
|
-
fiber.raise(::IO::TimeoutError, "Timeout while waiting for IO to become ready!")
|
244
|
+
fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become ready!")
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
@@ -256,7 +256,7 @@ module Async
|
|
256
256
|
|
257
257
|
if timeout = get_timeout(io)
|
258
258
|
timer = @timers.after(timeout) do
|
259
|
-
fiber.raise(::IO::TimeoutError, "Timeout while waiting for IO to become readable!")
|
259
|
+
fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become readable!")
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
@@ -271,7 +271,7 @@ module Async
|
|
271
271
|
|
272
272
|
if timeout = get_timeout(io)
|
273
273
|
timer = @timers.after(timeout) do
|
274
|
-
fiber.raise(::IO::TimeoutError, "Timeout while waiting for IO to become writable!")
|
274
|
+
fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become writable!")
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
data/lib/async/task.rb
CHANGED
@@ -67,6 +67,13 @@ module Async
|
|
67
67
|
Fiber.scheduler.transfer
|
68
68
|
end
|
69
69
|
|
70
|
+
# Run the given block of code in a task, asynchronously, in the given scheduler.
|
71
|
+
def self.run(scheduler, *arguments, **options, &block)
|
72
|
+
self.new(scheduler, **options, &block).tap do |task|
|
73
|
+
task.run(*arguments)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
70
77
|
# Create a new task.
|
71
78
|
# @parameter reactor [Reactor] the reactor this task will run within.
|
72
79
|
# @parameter parent [Task] the parent task.
|
data/lib/async/variable.rb
CHANGED
@@ -31,6 +31,8 @@ module Async
|
|
31
31
|
condition.signal(value)
|
32
32
|
end
|
33
33
|
|
34
|
+
alias value= resolve
|
35
|
+
|
34
36
|
# Whether the value has been resolved.
|
35
37
|
#
|
36
38
|
# @returns [Boolean] Whether the value has been resolved.
|
@@ -41,14 +43,11 @@ module Async
|
|
41
43
|
# Wait for the value to be resolved.
|
42
44
|
#
|
43
45
|
# @returns [Object] The resolved value.
|
44
|
-
def
|
46
|
+
def wait
|
45
47
|
@condition&.wait
|
46
48
|
return @value
|
47
49
|
end
|
48
50
|
|
49
|
-
|
50
|
-
def wait
|
51
|
-
self.value
|
52
|
-
end
|
51
|
+
alias value wait
|
53
52
|
end
|
54
53
|
end
|
data/lib/async/version.rb
CHANGED
data/lib/kernel/async.rb
CHANGED
data/lib/kernel/sync.rb
CHANGED
data/readme.md
CHANGED
@@ -31,6 +31,23 @@ Please see the [project documentation](https://socketry.github.io/async/) for mo
|
|
31
31
|
|
32
32
|
- [Debugging](https://socketry.github.io/async/guides/debugging/index) - This guide explains how to debug issues with programs that use Async.
|
33
33
|
|
34
|
+
## Releases
|
35
|
+
|
36
|
+
Please see the [project releases](https://socketry.github.io/async/releases/index) for all releases.
|
37
|
+
|
38
|
+
### v2.16.0
|
39
|
+
|
40
|
+
- [Better Handling of Async and Sync in Nested Fibers](https://socketry.github.io/async/releases/index#better-handling-of-async-and-sync-in-nested-fibers)
|
41
|
+
|
42
|
+
## See Also
|
43
|
+
|
44
|
+
- [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client/server.
|
45
|
+
- [async-websocket](https://github.com/socketry/async-websocket) — Asynchronous client and server websockets.
|
46
|
+
- [async-dns](https://github.com/socketry/async-dns) — Asynchronous DNS resolver and server.
|
47
|
+
- [falcon](https://github.com/socketry/falcon) — A rack compatible server built on top of `async-http`.
|
48
|
+
- [rubydns](https://github.com/ioquatix/rubydns) — An easy to use Ruby DNS server.
|
49
|
+
- [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot) — A client for making slack bots.
|
50
|
+
|
34
51
|
## Contributing
|
35
52
|
|
36
53
|
We welcome contributions to this project.
|
@@ -48,12 +65,3 @@ In order to protect users of this project, we require all contributors to comply
|
|
48
65
|
### Community Guidelines
|
49
66
|
|
50
67
|
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
51
|
-
|
52
|
-
## See Also
|
53
|
-
|
54
|
-
- [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client/server.
|
55
|
-
- [async-websocket](https://github.com/socketry/async-websocket) — Asynchronous client and server websockets.
|
56
|
-
- [async-dns](https://github.com/socketry/async-dns) — Asynchronous DNS resolver and server.
|
57
|
-
- [falcon](https://github.com/socketry/falcon) — A rack compatible server built on top of `async-http`.
|
58
|
-
- [rubydns](https://github.com/ioquatix/rubydns) — An easy to use Ruby DNS server.
|
59
|
-
- [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot) — A client for making slack bots.
|
data/releases.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Releases
|
2
|
+
|
3
|
+
## v2.16.0
|
4
|
+
|
5
|
+
### Better Handling of Async and Sync in Nested Fibers
|
6
|
+
|
7
|
+
Interleaving bare fibers within `Async` and `Sync` blocks should not cause problems, but it presents a number of issues in the current implementation. Tracking the parent-child relationship between tasks, when they are interleaved with bare fibers, is difficult. The current implementation assumes that if there is no parent task, then it should create a new reactor. This is not always the case, as the parent task might not be visible due to nested Fibers. As a result, `Async` will create a new reactor, trying to stop the existing one, causing major internal consistency issues.
|
8
|
+
|
9
|
+
I encountered this issue when trying to use `Async` within a streaming response in Rails. The `protocol-rack` [uses a normal fiber to wrap streaming responses](https://github.com/socketry/protocol-rack/blob/cb1ca44e9deadb9369bdb2ea03416556aa927c5c/lib/protocol/rack/body/streaming.rb#L24-L28), and if you try to use `Async` within it, it will create a new reactor, causing the server to lock up.
|
10
|
+
|
11
|
+
Ideally, `Async` and `Sync` helpers should work when any `Fiber.scheduler` is defined. Right now, it's unrealistic to expect `Async::Task` to work in any scheduler, but at the very least, the following should work:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
reactor = Async::Reactor.new # internally calls Fiber.set_scheduler
|
15
|
+
|
16
|
+
# This should run in the above reactor, rather than creating a new one.
|
17
|
+
Async do
|
18
|
+
puts "Hello World"
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
In order to do this, bare `Async` and `Sync` blocks should use `Fiber.scheduler` as a parent if possible.
|
23
|
+
|
24
|
+
See <https://github.com/socketry/async/pull/340> for more details.
|
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.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -63,7 +63,7 @@ cert_chain:
|
|
63
63
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
64
64
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
65
65
|
-----END CERTIFICATE-----
|
66
|
-
date: 2024-08-
|
66
|
+
date: 2024-08-26 00:00:00.000000000 Z
|
67
67
|
dependencies:
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: console
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/kernel/sync.rb
|
146
146
|
- license.md
|
147
147
|
- readme.md
|
148
|
+
- releases.md
|
148
149
|
homepage: https://github.com/socketry/async
|
149
150
|
licenses:
|
150
151
|
- MIT
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
rubygems_version: 3.5.
|
171
|
+
rubygems_version: 3.5.11
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: A concurrency framework for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|