From 2c10b48b7060a3742f2a4726c735b0cbc015a2f1 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 1 Nov 2021 13:31:11 +0100 Subject: [PATCH] Execute Command: Guard requesting new runner * If any exception is thrown, these will be caught now and handled appropriately --- app/models/runner.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/runner.rb b/app/models/runner.rb index e0bebd5e..d92b66bc 100644 --- a/app/models/runner.rb +++ b/app/models/runner.rb @@ -77,6 +77,11 @@ class Runner < ApplicationRecord stderr = +'' try = 0 begin + if try.nonzero? + request_new_id + save + end + exit_code = 1 # default to error execution_time = attach_to_execution(command) do |socket| socket.on :stderr do |data| @@ -96,8 +101,6 @@ class Runner < ApplicationRecord rescue Runner::Error::RunnerNotFound => e Rails.logger.debug { "Running command `#{command}` failed for the first time: #{e.message}" } try += 1 - request_new_id - save if try == 1 # Reset the variable. This is required to prevent raising an outdated exception after a successful second try