lib/zapp/worker_pool.rb in zapp-0.2.1 vs lib/zapp/worker_pool.rb in zapp-0.2.2
- old
+ new
@@ -7,18 +7,17 @@
SIGNALS = {
EXIT: :exit
}.freeze
- def initialize(app:, context_pipe:, socket_pipe:)
+ def initialize(context_pipe:, socket_pipe:)
@context_pipe = context_pipe
@workers = []
Zapp.config.parallelism.times do |i|
@workers << Worker.new(
context_pipe: context_pipe,
socket_pipe: socket_pipe,
- app: app,
index: i
)
end
end
@@ -28,11 +27,13 @@
end
# Finishes processing of all requests and shuts down workers
def drain
Zapp.config.parallelism.times { process(context: SIGNALS[:EXIT]) }
- workers.map(&:terminate)
- rescue Ractor::ClosedError
- # Ractor has already exited
+ workers.map do |w|
+ w.terminate
+ rescue Ractor::ClosedError
+ # Ractor has already exited
+ end
end
end
end