11170: Calling close method from an ensure block.
[arvados.git] / services / api / lib / crunch_dispatch.rb
index c95db312f4337bb95efccf72e66e01e3bd8cf4e7..bea1657de22b72c0d5296a4c571afcee3ffc0993 100644 (file)
@@ -964,9 +964,11 @@ class CrunchDispatch
   def squeue_jobs
     if Rails.configuration.crunch_job_wrapper == :slurm_immediate
       p = IO.popen(['squeue', '-a', '-h', '-o', '%j'])
-      l = p.readlines.map {|line| line.strip}
-      p.close
-      l
+      begin
+        p.readlines.map {|line| line.strip}
+      ensure
+        p.close
+      end
     else
       []
     end