From 55059b015f45900a10cb6a5102ee554e80222fc4 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Mon, 18 Oct 2021 15:32:06 -0400 Subject: [PATCH] Avoid resultsock shutdown before reading from it --- awx/main/tasks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index fd032653e2..b05e9ad719 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -3177,10 +3177,6 @@ class AWXReceptorJob: self.task.update_model(self.task.instance.pk, status='pending') return - # if we did not exceed the quota, continue with shutting down the job - resultsock.shutdown(socket.SHUT_RDWR) - resultfile.close() - # If ansible-runner ran, but an error occured at runtime, the traceback information # is saved via the status_handler passed in to the processor. if state_name == 'Succeeded': @@ -3193,8 +3189,13 @@ class AWXReceptorJob: self.task.instance.result_traceback = b"".join(lines).decode() self.task.instance.save(update_fields=['result_traceback']) except Exception: + resultsock.shutdown(socket.SHUT_RDWR) + resultfile.close() raise RuntimeError(detail) + resultsock.shutdown(socket.SHUT_RDWR) + resultfile.close() + time.sleep(3) return res