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


##########
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'm not very familiar with `threading.local()`, but I'm not sure it works 
like this. It's not a shared static storage for whoever is on the same thread, 
it still needs a common variable.
   For instance, consider the following sample code:
   ```
   import threading
   
   def set():
       setdata = threading.local()
       setdata.test = "hello"
   
   def get():
       getdata = threading.local()
       print(getdata.test)
   
   set()
   get()
   
   ```
   this crashes in `get()` because `getdata` is not the same instance as 
`setdata`.
   
   So we need somewhere to store our ThreadLocal variable that can be accessed 
from a different taskinstance method. I can actually move it outside of 
TaskInstance, to the global scope, or to any other classe for that matter, but 
I'm not sure it's a good idea.



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