lib/async/task.rb in async-2.10.2 vs lib/async/task.rb in async-2.11.0
- old
+ new
@@ -6,10 +6,11 @@
# Copyright, 2017, by Devin Christensen.
# Copyright, 2020, by Patrik Wenger.
# Copyright, 2023, by Math Ieu.
require 'fiber'
+require 'console/event/failure'
require_relative 'node'
require_relative 'condition'
module Async
@@ -333,19 +334,19 @@
if exception
if propagate
raise exception
elsif @finished.nil?
# If no one has called wait, we log this as a warning:
- Console.logger.warn(self, "Task may have ended with unhandled exception.", exception)
+ Console::Event::Failure.for(exception).emit(self, "Task may have ended with unhandled exception.", severity: :warn)
else
- Console.logger.debug(self, exception)
+ Console::Event::Failure.for(exception).emit(self, severity: :debug)
end
end
end
def stopped!
- # Console.logger.info(self, status:) {"Task #{self} was stopped with #{@children&.size.inspect} children!"}
+ # Console.info(self, status:) {"Task #{self} was stopped with #{@children&.size.inspect} children!"}
@status = :stopped
stopped = false
begin
@@ -372,18 +373,18 @@
@fiber = Fiber.new(annotation: self.annotation) do
set!
begin
completed!(yield)
- # Console.logger.debug(self) {"Task was completed with #{@children.size} children!"}
+ # Console.debug(self) {"Task was completed with #{@children.size} children!"}
rescue Stop
stopped!
rescue StandardError => error
failed!(error, false)
rescue Exception => exception
failed!(exception, true)
ensure
- # Console.logger.info(self) {"Task ensure $! = #{$!} with #{@children&.size.inspect} children!"}
+ # Console.info(self) {"Task ensure $! = #{$!} with #{@children&.size.inspect} children!"}
finish!
end
end
self.root.resume(@fiber)