Class: HotCell::Fixtures::EarlyIdle
- Defined in:
- lib/hot_cell/test_operations.rb
Overview
Reports itself idle while its request is still running, so the report and the truth disagree from
that moment on. The control socket is private to the Worker, but it lives in the operation's own
process, so reaching it takes one ObjectSpace walk. With exit_after, the worker then exits without
ever reading its control socket again, so whatever the supervisor wrote there in the meantime is
queued and unread when it goes.
Constant Summary
Constants inherited from Operation
Instance Method Summary collapse
Methods inherited from Operation
abstract_operation, abstract_operation?, before_fork, before_worker_boot, inherited, limits, operation, operation_name, #run_tool, unreadable
Instance Method Details
#perform(_inputs, _outputs, pid_path:, exit_after: nil) ⇒ Object
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/hot_cell/test_operations.rb', line 397 def perform(_inputs, _outputs, pid_path:, exit_after: nil) # The one with an open control socket, not `.first`: a suite that builds a Worker in its own # process leaves it on the heap for the fork to inherit, with its sockets closed by teardown. worker = ObjectSpace.each_object(HotCell::Worker).find do |candidate| !candidate.instance_variable_get(:@control).socket.closed? end worker.instance_variable_get(:@control).write_line JSON.generate(idle: true, code: "ok") << "\n" File.write pid_path, Process.pid.to_s if exit_after sleep exit_after exit! 0 else sleep 300 end end |