async 2.13.0 → 2.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/task.rb +22 -26
- data/lib/async/version.rb +1 -1
- data/readme.md +7 -10
- data.tar.gz.sig +2 -3
- metadata +3 -3
- 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: ffbf235f3425b766c8eedfcdb2b03f86569e43ab1cdda3bd44f74c1b25f516b7
|
4
|
+
data.tar.gz: 1d71883b2151b5eb0f23daf27221ac091d352809a0ef1f687f282696cd22ae79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a00499f9ea43ffee3e6a5cf65dee14f67c5dcd167cb68e1b5da7c11bcef51c06da9c8c2d7a0606f72e5802520f7b9837f128d8425ade3de75111ca16a4cc9c10
|
7
|
+
data.tar.gz: f65b60522c85e07a17fdc345944c06e7447095682afea0bd2b7dcbf462deeeb7dcb6053e82eefc96cc259b10d6b0849803b8f22356feb10a21666a5ab134f6d6
|
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("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.
|
@@ -354,21 +365,10 @@ module Async
|
|
354
365
|
@status = :completed
|
355
366
|
end
|
356
367
|
|
357
|
-
#
|
358
|
-
def failed!(exception = false
|
368
|
+
# State transition into the failed state.
|
369
|
+
def failed!(exception = false)
|
359
370
|
@result = exception
|
360
371
|
@status = :failed
|
361
|
-
|
362
|
-
if exception
|
363
|
-
if propagate
|
364
|
-
raise exception
|
365
|
-
elsif @finished.nil?
|
366
|
-
# If no one has called wait, we log this as a warning:
|
367
|
-
Console::Event::Failure.for(exception).emit(self, "Task may have ended with unhandled exception.", severity: :warn)
|
368
|
-
else
|
369
|
-
Console::Event::Failure.for(exception).emit(self, severity: :debug)
|
370
|
-
end
|
371
|
-
end
|
372
372
|
end
|
373
373
|
|
374
374
|
def stopped!
|
@@ -399,30 +399,26 @@ module Async
|
|
399
399
|
|
400
400
|
def schedule(&block)
|
401
401
|
@fiber = Fiber.new(annotation: self.annotation) do
|
402
|
-
set!
|
403
|
-
|
404
402
|
begin
|
405
403
|
completed!(yield)
|
406
|
-
# Console.debug(self) {"Task was completed with #{@children.size} children!"}
|
407
404
|
rescue Stop
|
408
405
|
stopped!
|
409
406
|
rescue StandardError => error
|
410
|
-
failed!(error
|
407
|
+
failed!(error)
|
411
408
|
rescue Exception => exception
|
412
|
-
failed!(exception
|
409
|
+
failed!(exception)
|
410
|
+
|
411
|
+
# This is a critical failure, we should stop the reactor:
|
412
|
+
raise
|
413
413
|
ensure
|
414
414
|
# Console.info(self) {"Task ensure $! = #{$!} with #{@children&.size.inspect} children!"}
|
415
415
|
finish!
|
416
416
|
end
|
417
417
|
end
|
418
418
|
|
419
|
+
@fiber.async_task = self
|
420
|
+
|
419
421
|
self.root.resume(@fiber)
|
420
422
|
end
|
421
|
-
|
422
|
-
# Set the current fiber's `:async_task` to this task.
|
423
|
-
def set!
|
424
|
-
# This is actually fiber-local:
|
425
|
-
Thread.current[:async_task] = self
|
426
|
-
end
|
427
423
|
end
|
428
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
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
���`�G���VhL�&�_����_�gǁ6��[�E:���nk�p����-Y���xD��gG�f�&�)��!�[5N1��Ο��Cc�l�ӕ
|
1
|
+
�(��6�d��Gl!剟��ץ�4��5��w�s�Ib��<^&5��5��@g�{\�rR_���O���o�e ĉ�F�s�RL6A*��LΆ��Ԏz5v-N�ZF�_\k�<H"`�D�*�[�P���sE`x�X��4�`v->�f`�ge�~?\�m�`�QB�&��y��uk ]^�=t�B}=�ԯ�\����ib�;�.2>����T�Y������&=����o��8�㱑�x�:����s��c�/^k��˷c?LqQ�ߤ�+�b���9L�E�p�CWx_���?z����hK�Y��I@;5�D�7t�lE��x�S�����!~ ᤪϪԆ��K�`-�f`��
|
2
|
+
�6�&s�9s�m�S�K�;U�o8��@
|
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.
|
4
|
+
version: 2.14.1
|
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-15 00:00:00.000000000 Z
|
66
66
|
dependencies:
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: console
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
|
-
rubygems_version: 3.5.
|
175
|
+
rubygems_version: 3.5.11
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: A concurrency framework for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|