async 2.14.0 → 2.14.2
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/task.rb +15 -17
- data/lib/async/version.rb +1 -1
- data/readme.md +7 -10
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12cf95e2d70376d5634d24377bb7d3d3974f14f20227fc33450fb103b17f5783
|
4
|
+
data.tar.gz: e0c89541d8d039ec1672b68ef1ae90a86a00c065f6143769734bcbf7cc01d7de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec85cadb861dd14ed374930963e94785e066b8584537e2ef0cc28d8a804372bcf7895f9836d436bd72e20d3f4e0027820ea005dff60120f3d0b66192571e82a
|
7
|
+
data.tar.gz: f11f62065e7fb9072f06b26514e98c33b6aac2988a485ebaf814792a68abe18711f9842187fcfa66282c8ce0290a1064c575a6d1f8cc5a18269f85f82886fc04
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/task.rb
CHANGED
@@ -13,6 +13,8 @@ require 'console/event/failure'
|
|
13
13
|
require_relative 'node'
|
14
14
|
require_relative 'condition'
|
15
15
|
|
16
|
+
Fiber.attr_accessor :async_task
|
17
|
+
|
16
18
|
module Async
|
17
19
|
# Raised when a task is explicitly stopped.
|
18
20
|
class Stop < Exception
|
@@ -186,6 +188,15 @@ module Async
|
|
186
188
|
|
187
189
|
schedule do
|
188
190
|
@block.call(self, *arguments)
|
191
|
+
rescue => error
|
192
|
+
# 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.
|
193
|
+
if @finished.nil?
|
194
|
+
Console::Event::Failure.for(error).emit(self, "Task may have ended with unhandled exception.", severity: :warn)
|
195
|
+
# else
|
196
|
+
# Console::Event::Failure.for(error).emit(self, severity: :debug)
|
197
|
+
end
|
198
|
+
|
199
|
+
raise
|
189
200
|
end
|
190
201
|
else
|
191
202
|
raise RuntimeError, "Task already running!"
|
@@ -316,13 +327,13 @@ module Async
|
|
316
327
|
# @returns [Task]
|
317
328
|
# @raises[RuntimeError] If task was not {set!} for the current fiber.
|
318
329
|
def self.current
|
319
|
-
|
330
|
+
Fiber.current.async_task or raise RuntimeError, "No async task available!"
|
320
331
|
end
|
321
332
|
|
322
333
|
# Check if there is a task defined for the current fiber.
|
323
334
|
# @returns [Interface(:async) | Nil]
|
324
335
|
def self.current?
|
325
|
-
|
336
|
+
Fiber.current.async_task
|
326
337
|
end
|
327
338
|
|
328
339
|
# @returns [Boolean] Whether this task is the currently executing task.
|
@@ -358,12 +369,6 @@ module Async
|
|
358
369
|
def failed!(exception = false)
|
359
370
|
@result = exception
|
360
371
|
@status = :failed
|
361
|
-
|
362
|
-
if $DEBUG
|
363
|
-
Fiber.blocking do
|
364
|
-
$stderr.puts "Task #{self} failed:", exception.full_message
|
365
|
-
end
|
366
|
-
end
|
367
372
|
end
|
368
373
|
|
369
374
|
def stopped!
|
@@ -394,11 +399,8 @@ module Async
|
|
394
399
|
|
395
400
|
def schedule(&block)
|
396
401
|
@fiber = Fiber.new(annotation: self.annotation) do
|
397
|
-
set!
|
398
|
-
|
399
402
|
begin
|
400
403
|
completed!(yield)
|
401
|
-
# Console.debug(self) {"Task was completed with #{@children.size} children!"}
|
402
404
|
rescue Stop
|
403
405
|
stopped!
|
404
406
|
rescue StandardError => error
|
@@ -414,13 +416,9 @@ module Async
|
|
414
416
|
end
|
415
417
|
end
|
416
418
|
|
419
|
+
@fiber.async_task = self
|
420
|
+
|
417
421
|
self.root.resume(@fiber)
|
418
422
|
end
|
419
|
-
|
420
|
-
# Set the current fiber's `:async_task` to this task.
|
421
|
-
def set!
|
422
|
-
# This is actually fiber-local:
|
423
|
-
Thread.current[:async_task] = self
|
424
|
-
end
|
425
423
|
end
|
426
424
|
end
|
data/lib/async/version.rb
CHANGED
data/readme.md
CHANGED
@@ -19,20 +19,17 @@ Async is a composable asynchronous I/O framework for Ruby based on [io-event](ht
|
|
19
19
|
|
20
20
|
Please see the [project documentation](https://socketry.github.io/async/) for more details.
|
21
21
|
|
22
|
-
- [Getting Started](https://socketry.github.io/async/guides/getting-started/index) - This guide shows how to add
|
23
|
-
async to your project and run code asynchronously.
|
22
|
+
- [Getting Started](https://socketry.github.io/async/guides/getting-started/index) - This guide shows how to add async to your project and run code asynchronously.
|
24
23
|
|
25
|
-
- [Asynchronous Tasks](https://socketry.github.io/async/guides/asynchronous-tasks/index) - This guide explains how
|
26
|
-
asynchronous tasks work and how to use them.
|
24
|
+
- [Asynchronous Tasks](https://socketry.github.io/async/guides/asynchronous-tasks/index) - This guide explains how asynchronous tasks work and how to use them.
|
27
25
|
|
28
|
-
- [Event Loop](https://socketry.github.io/async/guides/event-loop/index) - This guide gives an overview of how the
|
29
|
-
event loop is implemented.
|
26
|
+
- [Event Loop](https://socketry.github.io/async/guides/event-loop/index) - This guide gives an overview of how the event loop is implemented.
|
30
27
|
|
31
|
-
- [Compatibility](https://socketry.github.io/async/guides/compatibility/index) - This guide gives an overview of the
|
32
|
-
compatibility of Async with Ruby and other frameworks.
|
28
|
+
- [Compatibility](https://socketry.github.io/async/guides/compatibility/index) - This guide gives an overview of the compatibility of Async with Ruby and other frameworks.
|
33
29
|
|
34
|
-
- [Best Practices](https://socketry.github.io/async/guides/best-practices/index) - This guide gives an overview of
|
35
|
-
|
30
|
+
- [Best Practices](https://socketry.github.io/async/guides/best-practices/index) - This guide gives an overview of best practices for using Async.
|
31
|
+
|
32
|
+
- [Debugging](https://socketry.github.io/async/guides/debugging/index) - This guide explains how to debug issues with programs that use Async.
|
36
33
|
|
37
34
|
## Contributing
|
38
35
|
|
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.14.
|
4
|
+
version: 2.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -62,7 +62,7 @@ cert_chain:
|
|
62
62
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
63
63
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
64
64
|
-----END CERTIFICATE-----
|
65
|
-
date: 2024-07-
|
65
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
66
66
|
dependencies:
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: console
|
metadata.gz.sig
CHANGED
Binary file
|