mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
more gracefully account for undefined stdout
* It's possible to have an exception raised in BaseTask.run() before the stdout handler gets defined. This is problematic when the exception handler tries to access that undefined var .. causing another exception. Note that the second exception is caught also but it's not desirable to lose the first exception. * This fix checks to see if the stdout handler var is defined before calling it's methods. Thus, we retain the original error message.
This commit is contained in:
parent
47fa99d3ad
commit
7e7ff8137d
@ -993,9 +993,10 @@ class BaseTask(LogErrorsTask):
|
||||
logger.exception('%s Exception occurred while running task', instance.log_format)
|
||||
finally:
|
||||
try:
|
||||
stdout_handle.flush()
|
||||
stdout_handle.close()
|
||||
event_ct = getattr(stdout_handle, '_event_ct', 0)
|
||||
if stdout_handle:
|
||||
stdout_handle.flush()
|
||||
stdout_handle.close()
|
||||
event_ct = getattr(stdout_handle, '_event_ct', 0)
|
||||
logger.info('%s finished running, producing %s events.',
|
||||
instance.log_format, event_ct)
|
||||
except Exception:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user