Avoid resultsock shutdown before reading from it

This commit is contained in:
Alan Rominger 2021-10-18 15:32:06 -04:00 committed by Shane McDonald
parent eb6c58682d
commit 55059b015f
No known key found for this signature in database
GPG Key ID: 6F374AF6E9EB9374

View File

@ -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