Skip to content

Commit f1484a1

Browse files
committed
Drop support for Ruby v3.1 and related compatibility shims.
1 parent 437515e commit f1484a1

File tree

6 files changed

+45
-18
lines changed

6 files changed

+45
-18
lines changed

.github/workflows/test-coverage.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ jobs:
1717
strategy:
1818
matrix:
1919
include:
20-
- os: ubuntu
21-
ruby: "3.1"
22-
io_event_selector: EPoll
2320
- os: ubuntu
2421
ruby: "3.2"
2522
io_event_selector: EPoll

.github/workflows/test-external.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- macos
2121

2222
ruby:
23-
- "3.1"
2423
- "3.2"
2524
- "3.3"
2625
- "3.4"

.github/workflows/test.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
- macos
2222

2323
ruby:
24-
- "3.1"
2524
- "3.2"
2625
- "3.3"
2726
- "3.4"

lib/async/scheduler.rb

+3-13
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,6 @@ def address_resolve(hostname)
269269
::Resolv.getaddresses(hostname)
270270
end
271271

272-
if IO.method_defined?(:timeout)
273-
private def get_timeout(io)
274-
io.timeout
275-
end
276-
else
277-
private def get_timeout(io)
278-
nil
279-
end
280-
end
281-
282272
# Wait for the specified IO to become ready for the specified events.
283273
#
284274
# @public Since *Async v2*.
@@ -295,7 +285,7 @@ def io_wait(io, events, timeout = nil)
295285
timer = @timers.after(timeout) do
296286
fiber.transfer
297287
end
298-
elsif timeout = get_timeout(io)
288+
elsif timeout = io.timeout
299289
# Otherwise, if we default to the io's timeout, we raise an exception:
300290
timer = @timers.after(timeout) do
301291
fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become ready!")
@@ -320,7 +310,7 @@ def io_wait(io, events, timeout = nil)
320310
def io_read(io, buffer, length, offset = 0)
321311
fiber = Fiber.current
322312

323-
if timeout = get_timeout(io)
313+
if timeout = io.timeout
324314
timer = @timers.after(timeout) do
325315
fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become readable!")
326316
end
@@ -344,7 +334,7 @@ def io_read(io, buffer, length, offset = 0)
344334
def io_write(io, buffer, length, offset = 0)
345335
fiber = Fiber.current
346336

347-
if timeout = get_timeout(io)
337+
if timeout = io.timeout
348338
timer = @timers.after(timeout) do
349339
fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become writable!")
350340
end

releases.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Ruby v3.1 support is dropped.
6+
37
## v2.23.0
48

59
- Rename `ASYNC_SCHEDULER_DEFAULT_WORKER_POOL` to `ASYNC_SCHEDULER_WORKER_POOL`.

test/traces/provider/async/task.rb

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2025, by Samuel Williams.
5+
6+
require "traces"
7+
return unless Traces.enabled?
8+
9+
require "async"
10+
require "traces/provider/async/task"
11+
12+
describe Async::Task do
13+
it "traces tasks within active tracing" do
14+
context = nil
15+
16+
Thread.new do
17+
Traces.trace("test") do
18+
Async do
19+
context = Traces.trace_context
20+
end
21+
end
22+
end.join
23+
24+
expect(context).not.to be == nil
25+
end
26+
27+
it "doesn't trace tasks outside of active tracing" do
28+
expect(Traces).to receive(:active?).and_return(false)
29+
30+
context = nil
31+
32+
Async do
33+
context = Traces.trace_context
34+
end
35+
36+
expect(context).to be == nil
37+
end
38+
end

0 commit comments

Comments
 (0)