From 79e53c0eed77396cb37f60b48be0c60fe7e0ab89 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 20 Mar 2017 18:39:43 -0300 Subject: [PATCH 1/1] 11170: Treat the squeue/scancel calls as files instead of treating them as processes. Calling close when finished reading from them. --- services/api/lib/crunch_dispatch.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/services/api/lib/crunch_dispatch.rb b/services/api/lib/crunch_dispatch.rb index a66b4a02c2..7c9fa0a253 100644 --- a/services/api/lib/crunch_dispatch.rb +++ b/services/api/lib/crunch_dispatch.rb @@ -963,11 +963,10 @@ class CrunchDispatch # An array of job_uuids in squeue def squeue_jobs if Rails.configuration.crunch_job_wrapper == :slurm_immediate - p = File.popen(['squeue', '-a', '-h', '-o', '%j']) - # Avoid zombie processes stack up - Process.detach(p.pid) - p.readlines.map do |line| - line.strip + IO.popen(['squeue', '-a', '-h', '-o', '%j']) do |squeue_pipe| + squeue_pipe.readlines.map do |line| + line.strip + end end else [] @@ -976,10 +975,9 @@ class CrunchDispatch def scancel slurm_name cmd = sudo_preface + ['scancel', '-n', slurm_name] - p = File.popen(cmd) - # Avoid zombie processes stack up - Process.detach(p.pid) - puts p.read + IO.popen(cmd) do |scancel_pipe| + puts scancel_pipe.read + end if not $?.success? Rails.logger.error "scancel #{slurm_name.shellescape}: $?" end -- 2.30.2