Merge pull request #1192 from chrismeyersfsu/fix-stdout_handler_undefined

more gracefully account for undefined stdout
This commit is contained in:
Chris Meyers 2018-04-02 11:58:07 -04:00 committed by GitHub
commit 07aa99f949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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