ractorize 0.0.5 → 0.0.7
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
- data/CHANGELOG.md +8 -0
- data/src/ractorize/ractorized_object.rb +2 -1
- data/src/ractorize.rb +25 -14
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02d57de76c96c80c8fa5d7a49dcc54a12e9c7f849ff8951faba91806ff5dadbb
|
|
4
|
+
data.tar.gz: e6ae43cf484790673a4010505622b7255a09b7a5d04f358a2b5a8bec0ab6b917
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5034e676239f3e6ccd3ea1aa83a0923c0b439800127fd1a3444c08ce93de706f48b05f87e68d697cddb6612d42d7ca057b1b29adef5954ca5b51575cd1320050
|
|
7
|
+
data.tar.gz: 461059bac8aeea154ec67ed22ed530ac7f8921902bef688d7a5d21927e67adaaab582e2bc528b7a556b4c1fb733a37b9a9202bf261eb6d048125761d516a720f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [0.0.7] - 2026-06-06
|
|
2
|
+
|
|
3
|
+
- Closed Ractor::Ports sometimes give IOError instead of Ractor::ClosedError so handle both
|
|
4
|
+
|
|
5
|
+
## [0.0.6] - 2026-06-06
|
|
6
|
+
|
|
7
|
+
- Fix a bug where a closed port mysteriously breaks out of Kernel#loop
|
|
8
|
+
|
|
1
9
|
## [0.0.5] - 2026-05-30
|
|
2
10
|
|
|
3
11
|
- Support auto-freezing certain method-arguments
|
|
@@ -72,7 +72,8 @@ module Ractorize
|
|
|
72
72
|
def method_missing(method_name, *args, **opts, &block)
|
|
73
73
|
if @ractor.default_port.closed?
|
|
74
74
|
::Kernel.raise ::Ractor::ClosedError,
|
|
75
|
-
"You already closed this Ractorized
|
|
75
|
+
"You already closed this Ractorized instance of #{@__target_class__}!\n" \
|
|
76
|
+
"No more methods can be sent to it but you sent #{method_name}"
|
|
76
77
|
end
|
|
77
78
|
|
|
78
79
|
return_port = ::Ractor::Port.new
|
data/src/ractorize.rb
CHANGED
|
@@ -220,12 +220,12 @@ module Ractorize
|
|
|
220
220
|
klass = receive
|
|
221
221
|
target_class = klass
|
|
222
222
|
|
|
223
|
-
args, opts, block =
|
|
223
|
+
args, opts, block = Ractorize.extract_args(self)
|
|
224
224
|
|
|
225
225
|
klass.new(*args.freeze, **opts.freeze, &block)
|
|
226
226
|
else
|
|
227
227
|
# :nocov:
|
|
228
|
-
|
|
228
|
+
raise "Invalid mode #{mode}"
|
|
229
229
|
# :nocov:
|
|
230
230
|
end
|
|
231
231
|
|
|
@@ -243,14 +243,14 @@ module Ractorize
|
|
|
243
243
|
return_port << args_port
|
|
244
244
|
|
|
245
245
|
method_name = args_port.receive
|
|
246
|
-
method_args, opts =
|
|
246
|
+
method_args, opts = Ractorize.extract_args(args_port)
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
if block_given
|
|
250
|
-
block_result_port =
|
|
250
|
+
block_result_port = Ractor::Port.new
|
|
251
251
|
|
|
252
252
|
value = object.__send__(method_name, *method_args, **opts) do |*args, **opts, &b|
|
|
253
|
-
|
|
253
|
+
Ractorize.prepare_args(target_class, args, opts, skip_move: true)
|
|
254
254
|
|
|
255
255
|
return_port << [:yield, [args.dup.freeze, opts.dup.freeze, b].freeze, block_result_port].freeze
|
|
256
256
|
|
|
@@ -263,7 +263,7 @@ module Ractorize
|
|
|
263
263
|
break return_value
|
|
264
264
|
else
|
|
265
265
|
# :nocov:
|
|
266
|
-
|
|
266
|
+
raise "Not sure how to handle outcome_type #{outcome_type}"
|
|
267
267
|
# :nocov:
|
|
268
268
|
end
|
|
269
269
|
end
|
|
@@ -271,10 +271,21 @@ module Ractorize
|
|
|
271
271
|
return_port << [:return, value].freeze
|
|
272
272
|
else
|
|
273
273
|
value = object.__send__(method_name, *method_args, **opts)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
value = value.__value__ while Ractorize::Thunk === value
|
|
275
|
+
|
|
276
|
+
begin
|
|
277
|
+
return_port.send(value)
|
|
278
|
+
rescue IOError => e
|
|
279
|
+
# Unclear why this sometimes manifests as this error instead of ClosedError but
|
|
280
|
+
# need to handle them both.
|
|
281
|
+
# :nocov:
|
|
282
|
+
raise unless e.message == "closed stream"
|
|
283
|
+
# :nocov:
|
|
284
|
+
rescue Ractor::ClosedError
|
|
285
|
+
# Whoa... this error inherits from StopIteration and will kill the loop!!!
|
|
286
|
+
# Nothing really to do here but keep the loop going and handle other
|
|
287
|
+
# method calls to the ractorized object from other ractors.
|
|
288
|
+
end
|
|
278
289
|
end
|
|
279
290
|
end
|
|
280
291
|
end
|
|
@@ -282,10 +293,10 @@ module Ractorize
|
|
|
282
293
|
object
|
|
283
294
|
rescue => e
|
|
284
295
|
# :nocov:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
296
|
+
puts
|
|
297
|
+
puts "an unhandled error!!! #{e.class} #{e.message} #{e}"
|
|
298
|
+
puts e.backtrace
|
|
299
|
+
puts
|
|
289
300
|
|
|
290
301
|
raise
|
|
291
302
|
# :nocov:
|