diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 232e2aca..f2a38c30 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -17,9 +17,6 @@ jobs: strategy: matrix: include: - - os: ubuntu - ruby: "3.1" - io_event_selector: EPoll - os: ubuntu ruby: "3.2" io_event_selector: EPoll diff --git a/.github/workflows/test-external.yaml b/.github/workflows/test-external.yaml index c9cc200b..217a86a2 100644 --- a/.github/workflows/test-external.yaml +++ b/.github/workflows/test-external.yaml @@ -20,7 +20,6 @@ jobs: - macos ruby: - - "3.1" - "3.2" - "3.3" - "3.4" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5d597faa..6810b591 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,7 +21,6 @@ jobs: - macos ruby: - - "3.1" - "3.2" - "3.3" - "3.4" diff --git a/lib/async/scheduler.rb b/lib/async/scheduler.rb index ccea68e7..22e39db3 100644 --- a/lib/async/scheduler.rb +++ b/lib/async/scheduler.rb @@ -269,16 +269,6 @@ def address_resolve(hostname) ::Resolv.getaddresses(hostname) end - if IO.method_defined?(:timeout) - private def get_timeout(io) - io.timeout - end - else - private def get_timeout(io) - nil - end - end - # Wait for the specified IO to become ready for the specified events. # # @public Since *Async v2*. @@ -295,7 +285,7 @@ def io_wait(io, events, timeout = nil) timer = @timers.after(timeout) do fiber.transfer end - elsif timeout = get_timeout(io) + elsif timeout = io.timeout # Otherwise, if we default to the io's timeout, we raise an exception: timer = @timers.after(timeout) do 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) def io_read(io, buffer, length, offset = 0) fiber = Fiber.current - if timeout = get_timeout(io) + if timeout = io.timeout timer = @timers.after(timeout) do fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become readable!") end @@ -344,7 +334,7 @@ def io_read(io, buffer, length, offset = 0) def io_write(io, buffer, length, offset = 0) fiber = Fiber.current - if timeout = get_timeout(io) + if timeout = io.timeout timer = @timers.after(timeout) do fiber.raise(::IO::TimeoutError, "Timeout (#{timeout}s) while waiting for IO to become writable!") end diff --git a/releases.md b/releases.md index 2d40c6de..8531fc93 100644 --- a/releases.md +++ b/releases.md @@ -1,5 +1,9 @@ # Releases +## Unreleased + + - Ruby v3.1 support is dropped. + ## v2.23.0 - Rename `ASYNC_SCHEDULER_DEFAULT_WORKER_POOL` to `ASYNC_SCHEDULER_WORKER_POOL`. diff --git a/test/traces/provider/async/task.rb b/test/traces/provider/async/task.rb new file mode 100644 index 00000000..29d77c07 --- /dev/null +++ b/test/traces/provider/async/task.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# Released under the MIT License. +# Copyright, 2025, by Samuel Williams. + +require "traces" +return unless Traces.enabled? + +require "async" +require "traces/provider/async/task" + +describe Async::Task do + it "traces tasks within active tracing" do + context = nil + + Thread.new do + Traces.trace("test") do + Async do + context = Traces.trace_context + end + end + end.join + + expect(context).not.to be == nil + end + + it "doesn't trace tasks outside of active tracing" do + expect(Traces).to receive(:active?).and_return(false) + + context = nil + + Async do + context = Traces.trace_context + end + + expect(context).to be == nil + end +end