async 2.40.0 → 2.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58621f01c092a84a7cf528ed883d25b167fbc9be35cb85547b6f7f4d744d4f92
4
- data.tar.gz: 2543abb1cf45a52ba369af6e86aa6c93c29d9ece5dda28f3a846d28f16a49cb0
3
+ metadata.gz: c707fb6001b639a32c63b2eac330cde48e8d411dc766fca44b98816991f4daea
4
+ data.tar.gz: cff7be5da559c06c9d040717057270d9e2369f26b9ac481fa56e92d8383103b5
5
5
  SHA512:
6
- metadata.gz: f2696102d8dbfa20b3f55ebeb772f5c536ab20b160383ab3d5a6b42a8b402e674fc4b10115fb20be45537e33e615d971f00b1d9b8a43611ab6b6bf64fa163351
7
- data.tar.gz: 38ec316c57fe4bf60447b6e6406d41acfe0eded9d6f2ed8e6d64e221b08bf75d4e6e3110969d469ab37518116b50d0a7e65021ce896fb078fe8871a3fb9675ff
6
+ metadata.gz: 8ff5660626ce3c460bfe1b5796185a3421c5b060da99624a0fcf8943e2a634c5c5f1919ca281d29debaf04687ed5be6b7f70c36cf63a12bd96a776a06ec7e3ac
7
+ data.tar.gz: c5d0a80e1f6795afabd7b0ae1f5dda8d3d9f5083be0cbb2b5cb121977e389b68c71ef87e875d521bed65080652be5e5843061f32247a6bab35ef20e1d06e5484
checksums.yaml.gz.sig CHANGED
Binary file
@@ -525,12 +525,25 @@ module Async
525
525
  cancel
526
526
  end
527
527
 
528
- private def run_loop(&block)
528
+ # Run the event loop, until the scheduler is interrupted or finished.
529
+ #
530
+ # @parameter initial [Proc | Nil] The initial block to execute before the first loop iteration.
531
+ # @yields {...} The block to execute on each loop iteration.
532
+ # @raises {Interrupt} If the scheduler is interrupted.
533
+ private def run_loop(initial = nil, &block)
529
534
  interrupt = nil
530
535
 
531
536
  begin
532
537
  # In theory, we could use Exception here to be a little bit safer, but we've only shown the case for SignalException to be a problem, so let's not over-engineer this.
533
538
  Thread.handle_interrupt(::SignalException => :never) do
539
+ if initial
540
+ begin
541
+ initial.call
542
+ ensure
543
+ initial = nil
544
+ end
545
+ end
546
+
534
547
  until self.interrupted?
535
548
  # If we are finished, we need to exit:
536
549
  break unless yield
@@ -570,9 +583,15 @@ module Async
570
583
  begin
571
584
  @profiler&.start
572
585
 
573
- initial_task = self.async(...) if block_given?
586
+ initial_task = nil
574
587
 
575
- self.run_loop do
588
+ if block_given?
589
+ initial = proc do
590
+ initial_task = self.async(...)
591
+ end
592
+ end
593
+
594
+ self.run_loop(initial) do
576
595
  run_once
577
596
  end
578
597
 
data/lib/async/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Async
8
- VERSION = "2.40.0"
8
+ VERSION = "2.41.0"
9
9
  end
data/lib/kernel/sync.rb CHANGED
@@ -32,8 +32,7 @@ module Kernel
32
32
 
33
33
  begin
34
34
  # Use finished: false to suppress warnings since we're handling exceptions explicitly
35
- task = reactor.async(annotation: annotation, finished: false, &block)
36
- reactor.run
35
+ task = reactor.run(annotation: annotation, finished: false, &block)
37
36
  return task.wait
38
37
  ensure
39
38
  Fiber.set_scheduler(nil)
data/readme.md CHANGED
@@ -35,6 +35,10 @@ Please see the [project documentation](https://socketry.github.io/async/) for mo
35
35
 
36
36
  Please see the [project releases](https://socketry.github.io/async/releases/index) for all releases.
37
37
 
38
+ ### v2.41.0
39
+
40
+ - **Fixed**: Protect initial task from Interrupt exceptions.
41
+
38
42
  ### v2.40.0
39
43
 
40
44
  - Introduce `Async::Condition#waiting_count`. This allows you to see how many tasks are currently waiting on the condition, which can be useful for debugging and monitoring purposes.
@@ -75,10 +79,6 @@ Please see the [project releases](https://socketry.github.io/async/releases/inde
75
79
 
76
80
  - Fix incorrect handling of spurious wakeups in `Async::Promise#wait`, which could lead to premature (incorrect) resolution of the promise.
77
81
 
78
- ### v2.35.0
79
-
80
- - `Process.fork` is now properly handled by the Async fiber scheduler, ensuring that the scheduler state is correctly reset in the child process after a fork. This prevents issues where the child process inherits the scheduler state from the parent, which could lead to unexpected behavior.
81
-
82
82
  ## See Also
83
83
 
84
84
  - [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client/server.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v2.41.0
4
+
5
+ - **Fixed**: Protect initial task from Interrupt exceptions.
6
+
3
7
  ## v2.40.0
4
8
 
5
9
  - Introduce `Async::Condition#waiting_count`. This allows you to see how many tasks are currently waiting on the condition, which can be useful for debugging and monitoring purposes.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.40.0
4
+ version: 2.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file