You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/31 18:49:56 UTC
[GitHub] [airflow] uranusjr commented on a diff in pull request #26040: Fix TaskInstance.task not defined before handle_failure
uranusjr commented on code in PR #26040:
URL: https://github.com/apache/airflow/pull/26040#discussion_r959912182
##########
airflow/models/log.py:
##########
@@ -55,7 +55,7 @@ def __init__(self, event, task_instance=None, owner=None, extra=None, **kwargs):
self.task_id = task_instance.task_id
self.execution_date = task_instance.execution_date
self.map_index = task_instance.map_index
- if task_instance.task:
+ if hasattr(task_instance, 'task') and task_instance.task:
task_owner = task_instance.task.owner
Review Comment:
`hasattr` is actually just internally `try` + `getattr` so it’s probably better to do
```python
task = getattr(task_instance, "task", None)
if task:
task_owner = task.task_owner
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org