Skip to content

Commit

Permalink
Drop dependency on console gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 5, 2024
1 parent 19c9298 commit 6bca639
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion async.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = ">= 3.1"

spec.add_dependency "console", "~> 1.26"
spec.add_dependency "fiber-annotation"
spec.add_dependency "io-event", ["~> 1.6", ">= 1.6.5"]
end
2 changes: 0 additions & 2 deletions lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

require "io/event"

require "console"
require "resolv"

module Async
Expand Down Expand Up @@ -434,7 +433,6 @@ def async(*arguments, **options, &block)
# - Avoid scheduler overhead if no blocking operation is performed.
task.run(*arguments)

# Console.debug "Initial execution of task #{fiber} complete (#{result} -> #{fiber.alive?})..."
return task
end

Expand Down
5 changes: 1 addition & 4 deletions lib/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Copyright, 2023, by Math Ieu.

require "fiber"
require "console/event/failure"

require_relative "node"
require_relative "condition"
Expand Down Expand Up @@ -198,9 +197,7 @@ def run(*arguments)
rescue => error
# I'm not completely happy with this overhead, but the alternative is to not log anything which makes debugging extremely difficult. Maybe we can introduce a debug wrapper which adds extra logging.
if @finished.nil?
Console::Event::Failure.for(error).emit(self, "Task may have ended with unhandled exception.", severity: :warn)
else
# Console::Event::Failure.for(error).emit(self, severity: :debug)
warn self, "Task may have ended with unhandled exception.", error
end

raise
Expand Down
5 changes: 4 additions & 1 deletion test/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,10 @@ def sleep_forever

with "#result" do
it "does not raise exception" do
task = reactor.async do
task = reactor.async do |task|
# This prevents any logging and also any non-blocking behaviour, e.g. `io_write`...
expect(task).to receive(:warn).and_return(nil)

raise "The space time converter has failed."
end

Expand Down

0 comments on commit 6bca639

Please sign in to comment.