Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- macos

ruby:
- "3.1"
- "3.2"
- "3.3"
- "3.4"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
- macos

ruby:
- "3.1"
- "3.2"
- "3.3"
- "3.4"
Expand Down
16 changes: 3 additions & 13 deletions lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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*.
Expand All @@ -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!")
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions releases.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
38 changes: 38 additions & 0 deletions test/traces/provider/async/task.rb
Original file line number Diff line number Diff line change
@@ -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
Loading