Skip to content

Commit 4cb9ff6

Browse files
committed
Ensure fiber is blocking so that forked process starts in blocking context.
1 parent 2b01214 commit 4cb9ff6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/async/container/generic.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def spawn(name: nil, restart: false, key: nil, &block)
161161

162162
@statistics.spawn!
163163

164-
Fiber.new do
164+
fiber do
165165
while @running
166166
child = self.start(name, &block)
167167

@@ -270,6 +270,18 @@ def delete(key, child)
270270

271271
@state.delete(child)
272272
end
273+
274+
private
275+
276+
if Fiber.respond_to?(:blocking)
277+
def fiber(&block)
278+
Fiber.new(blocking: true, &block)
279+
end
280+
else
281+
def fiber(&block)
282+
Fiber.new(&block)
283+
end
284+
end
273285
end
274286
end
275287
end

0 commit comments

Comments
 (0)