potiuk commented on code in PR #38155:
URL: https://github.com/apache/airflow/pull/38155#discussion_r1556148549


##########
airflow/models/taskinstance.py:
##########
@@ -1409,7 +1410,9 @@ class TaskInstance(Base, LoggingMixin):
         cascade="all, delete, delete-orphan",
     )
     note = association_proxy("task_instance_note", "content", 
creator=_creator_note)
+
     task: Operator | None = None
+    _thread_local_data = threading.local()

Review Comment:
   I just look at this more closely. Hmm. I don't think we shouldadd the thread 
local data to task instance - why would we need to do it? The whole point of 
thread local data - is that you can access is directly whithout setting a 
variable to the model object that is passed down the stack.
   
   What I **really** thought about is literally two methods in 
`taskinstance.py`:
   
   ```python
   def set_last_error(error: None | str | BaseException:):
   ```
   
   ```python
   def get_last_error() -> None | str | BaseException:
   ```
   
   Both using ThreadLocal. No passing extra field in TaskInstance. 



##########
airflow/models/taskinstance.py:
##########
@@ -1409,7 +1410,9 @@ class TaskInstance(Base, LoggingMixin):
         cascade="all, delete, delete-orphan",
     )
     note = association_proxy("task_instance_note", "content", 
creator=_creator_note)
+
     task: Operator | None = None
+    _thread_local_data = threading.local()

Review Comment:
   I just look at this more closely. Hmm. I don't think we should add the 
thread local data to task instance - why would we need to do it? The whole 
point of thread local data - is that you can access is directly whithout 
setting a variable to the model object that is passed down the stack.
   
   What I **really** thought about is literally two methods in 
`taskinstance.py`:
   
   ```python
   def set_last_error(error: None | str | BaseException:):
   ```
   
   ```python
   def get_last_error() -> None | str | BaseException:
   ```
   
   Both using ThreadLocal. No passing extra field in TaskInstance. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to