From b4f871dd2c9ad9672f8b69d0849400367adf0bd0 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 16 Apr 2024 23:56:20 +1200 Subject: [PATCH 1/5] Add tea.xyz constitution file. --- tea.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tea.yaml diff --git a/tea.yaml b/tea.yaml new file mode 100644 index 00000000..cfafe795 --- /dev/null +++ b/tea.yaml @@ -0,0 +1,6 @@ +# https://tea.xyz/what-is-this-file +--- +version: 1.0.0 +codeOwners: + - '0x03d7E2c0cf7813867DDb318674B66CC53B8497dA' +quorum: 1 From 44272b4266cc2671a11563a9a8c3ef62b367d017 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 4 May 2024 18:50:06 +1200 Subject: [PATCH 2/5] Fix external tests `rspec` -> `sus`. --- config/external.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/external.yaml b/config/external.yaml index 1e2f6de4..ec05f2c4 100644 --- a/config/external.yaml +++ b/config/external.yaml @@ -18,4 +18,4 @@ falcon: command: bundle exec sus async-rest: url: https://github.com/socketry/async-rest.git - command: bundle exec rspec + command: bundle exec sus From 85c287132588305b19088a91bdcdce89466711aa Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 4 May 2024 19:13:23 +1200 Subject: [PATCH 3/5] Update dependency on `console` gem and modernize usage. (#315) --- async.gemspec | 2 +- examples/capture/capture.rb | 12 ++++++------ examples/hup-test/child.rb | 2 +- examples/hup-test/main.rb | 6 +++--- lib/async/barrier.md | 4 ++-- lib/async/condition.md | 6 +++--- lib/async/scheduler.rb | 4 ++-- lib/async/semaphore.md | 4 ++-- lib/async/task.rb | 11 ++++++----- lib/async/waiter.md | 2 +- test/async/task.rb | 2 +- test/kernel/sync.rb | 2 +- 12 files changed, 29 insertions(+), 28 deletions(-) diff --git a/async.gemspec b/async.gemspec index 9d7412d1..ae7b6f01 100644 --- a/async.gemspec +++ b/async.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 3.1.1" - spec.add_dependency "console", "~> 1.10" + spec.add_dependency "console", ["~> 1.25", ">= 1.25.2"] spec.add_dependency "fiber-annotation" spec.add_dependency "io-event", ["~> 1.5", ">= 1.5.1"] spec.add_dependency "timers", "~> 4.1" diff --git a/examples/capture/capture.rb b/examples/capture/capture.rb index ccbd619a..4df41f3f 100755 --- a/examples/capture/capture.rb +++ b/examples/capture/capture.rb @@ -83,7 +83,7 @@ def strace(pid, duration = 60) _, status = Process.waitpid2(pid) - Console.logger.error(status) do |buffer| + Console.error(status) do |buffer| buffer.puts first_line end unless status.success? @@ -92,28 +92,28 @@ def strace(pid, duration = 60) pids.each do |pid| start_times = getrusage(pid) - Console.logger.info("Process #{pid} start times:", start_times) + Console.info("Process #{pid} start times:", start_times) # sleep 60 summary = strace(pid) - Console.logger.info("strace -p #{pid}") do |buffer| + Console.info("strace -p #{pid}") do |buffer| summary.each do |fields| buffer.puts fields.inspect end end end_times = getrusage(pid) - Console.logger.info("Process #{pid} end times:", end_times) + Console.info("Process #{pid} end times:", end_times) if total = summary[:total] process_duration = end_times.utime - start_times.utime wait_duration = summary[:total][:seconds] - Console.logger.info("Process Waiting: #{wait_duration.round(4)}s out of #{process_duration.round(4)}s") do |buffer| + Console.info("Process Waiting: #{wait_duration.round(4)}s out of #{process_duration.round(4)}s") do |buffer| buffer.puts "Wait percentage: #{(wait_duration / process_duration * 100.0).round(2)}%" end else - Console.logger.warn("No system calls detected.") + Console.warn("No system calls detected.") end end diff --git a/examples/hup-test/child.rb b/examples/hup-test/child.rb index a98c4f1f..171647ff 100755 --- a/examples/hup-test/child.rb +++ b/examples/hup-test/child.rb @@ -10,7 +10,7 @@ Async do |task| while true task.async do - Console.logger.info("Child running.") + Console.info("Child running.") sleep 0.1 end.wait end diff --git a/examples/hup-test/main.rb b/examples/hup-test/main.rb index 3a989431..b3851bcd 100755 --- a/examples/hup-test/main.rb +++ b/examples/hup-test/main.rb @@ -8,10 +8,10 @@ while true pid = Process.spawn("./child.rb") - Console.logger.info("Spawned child.", pid: pid) + Console.info("Spawned child.", pid: pid) sleep 2 - Console.logger.info("Sending HUP to child.", pid: pid) + Console.info("Sending HUP to child.", pid: pid) Process.kill(:HUP, pid) status = Process.waitpid(pid) - Console.logger.info("Child exited.", pid: pid, status: status) + Console.info("Child exited.", pid: pid, status: status) end diff --git a/lib/async/barrier.md b/lib/async/barrier.md index d20667c7..13fe102a 100644 --- a/lib/async/barrier.md +++ b/lib/async/barrier.md @@ -9,7 +9,7 @@ require 'async/barrier' barrier = Async::Barrier.new Sync do - Console.logger.info("Barrier Example: sleep sort.") + Console.info("Barrier Example: sleep sort.") # Generate an array of 10 numbers: numbers = 10.times.map{rand(10)} @@ -26,7 +26,7 @@ Sync do # Wait for all the numbers to be sorted: barrier.wait - Console.logger.info("Sorted", sorted) + Console.info("Sorted", sorted) ensure # Ensure all the tasks are stopped when we exit: barrier.stop diff --git a/lib/async/condition.md b/lib/async/condition.md index 5d9b3072..d853a178 100644 --- a/lib/async/condition.md +++ b/lib/async/condition.md @@ -9,14 +9,14 @@ Sync do condition = Async::Condition.new Async do - Console.logger.info "Waiting for condition..." + Console.info "Waiting for condition..." value = condition.wait - Console.logger.info "Condition was signalled: #{value}" + Console.info "Condition was signalled: #{value}" end Async do |task| task.sleep(1) - Console.logger.info "Signalling condition..." + Console.info "Signalling condition..." condition.signal("Hello World") end end diff --git a/lib/async/scheduler.rb b/lib/async/scheduler.rb index 3b2703f1..8a5bdd4f 100644 --- a/lib/async/scheduler.rb +++ b/lib/async/scheduler.rb @@ -369,7 +369,7 @@ def run(...) return initial_task ensure - Console.logger.debug(self) {"Exiting run-loop because #{$! ? $! : 'finished'}."} + Console.debug(self) {"Exiting run-loop because #{$! ? $! : 'finished'}."} end # Start an asynchronous task within the specified reactor. The task will be @@ -395,7 +395,7 @@ def async(*arguments, **options, &block) # - Avoid scheduler overhead if no blocking operation is performed. task.run(*arguments) - # Console.logger.debug "Initial execution of task #{fiber} complete (#{result} -> #{fiber.alive?})..." + # Console.debug "Initial execution of task #{fiber} complete (#{result} -> #{fiber.alive?})..." return task end diff --git a/lib/async/semaphore.md b/lib/async/semaphore.md index 38ee4630..2524693d 100644 --- a/lib/async/semaphore.md +++ b/lib/async/semaphore.md @@ -17,9 +17,9 @@ Sync do # Search for the terms: terms.each do |term| semaphore.async do |task| - Console.logger.info("Searching for #{term}...") + Console.info("Searching for #{term}...") response = Net::HTTP.get(URI "https://www.google.com/search?q=#{term}") - Console.logger.info("Got response #{response.size} bytes.") + Console.info("Got response #{response.size} bytes.") end end end diff --git a/lib/async/task.rb b/lib/async/task.rb index 97a6f00d..c38d6470 100644 --- a/lib/async/task.rb +++ b/lib/async/task.rb @@ -8,6 +8,7 @@ # Copyright, 2023, by Math Ieu. require 'fiber' +require 'console/event/failure' require_relative 'node' require_relative 'condition' @@ -335,15 +336,15 @@ def failed!(exception = false, propagate = true) 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 @@ -374,7 +375,7 @@ def schedule(&block) 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 @@ -382,7 +383,7 @@ def schedule(&block) 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 diff --git a/lib/async/waiter.md b/lib/async/waiter.md index e5d49dc2..3a1270cb 100644 --- a/lib/async/waiter.md +++ b/lib/async/waiter.md @@ -38,7 +38,7 @@ Sync do # Stop all tasks which we don't care about: barrier.stop - Console.logger.info("Smallest", numbers) + Console.info("Smallest", numbers) end ~~~ diff --git a/test/async/task.rb b/test/async/task.rb index 82d5c7b8..850e18e2 100644 --- a/test/async/task.rb +++ b/test/async/task.rb @@ -761,7 +761,7 @@ def sleep_forever expect(task.result).to be_nil - Console.logger.debug(self) {"Stopping task..."} + Console.debug(self) {"Stopping task..."} task.stop expect(task.result).to be_nil diff --git a/test/kernel/sync.rb b/test/kernel/sync.rb index ce2948f5..8851d555 100644 --- a/test/kernel/sync.rb +++ b/test/kernel/sync.rb @@ -36,7 +36,7 @@ end it "can propagate error without logging them" do - expect(Console.logger).not.to receive(:error) + expect(Console).not.to receive(:error) expect do Sync do From 317a6ce62ec72316669d095516ea88ab459376d2 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 4 May 2024 19:27:17 +1200 Subject: [PATCH 4/5] Modernize gem. --- .github/workflows/documentation.yaml | 4 ++-- examples/capture/capture.rb | 2 +- examples/hup-test/child.rb | 2 +- examples/hup-test/main.rb | 2 +- test/kernel/sync.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 8dc52272..f5f553a0 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -40,7 +40,7 @@ jobs: run: bundle exec bake utopia:project:static --force no - name: Upload documentation artifact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 with: path: docs @@ -55,4 +55,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v3 + uses: actions/deploy-pages@v4 diff --git a/examples/capture/capture.rb b/examples/capture/capture.rb index 4df41f3f..4f9ded99 100755 --- a/examples/capture/capture.rb +++ b/examples/capture/capture.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2022, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. require 'irb' require 'console' diff --git a/examples/hup-test/child.rb b/examples/hup-test/child.rb index 171647ff..42dfb741 100755 --- a/examples/hup-test/child.rb +++ b/examples/hup-test/child.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023, by Samuel Williams. +# Copyright, 2023-2024, by Samuel Williams. require_relative '../../lib/async' require 'console' diff --git a/examples/hup-test/main.rb b/examples/hup-test/main.rb index b3851bcd..6fea2f8b 100755 --- a/examples/hup-test/main.rb +++ b/examples/hup-test/main.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023, by Samuel Williams. +# Copyright, 2023-2024, by Samuel Williams. require 'console' diff --git a/test/kernel/sync.rb b/test/kernel/sync.rb index 8851d555..a7b477f8 100644 --- a/test/kernel/sync.rb +++ b/test/kernel/sync.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2019-2022, by Samuel Williams. +# Copyright, 2019-2024, by Samuel Williams. # Copyright, 2020, by Brian Morearty. require 'kernel/async' From 43f15592266ebfc68759a2b93e7590189b3224e9 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 4 May 2024 19:41:27 +1200 Subject: [PATCH 5/5] Bump minor version. --- lib/async/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/async/version.rb b/lib/async/version.rb index d28353e6..03c71089 100644 --- a/lib/async/version.rb +++ b/lib/async/version.rb @@ -4,5 +4,5 @@ # Copyright, 2017-2024, by Samuel Williams. module Async - VERSION = "2.10.2" + VERSION = "2.11.0" end