sjyangkevin commented on issue #52574:
URL: https://github.com/apache/airflow/issues/52574#issuecomment-3130642118

   Thanks for the insightful feedback. I am trying to understand the mechanism 
better. 
   
   >the task runner does not commit the asset changes to the database before 
calling the callbacks and listeners.
   
   >when you call get_template_context in the listener you get a brand new 
context object that does not contain changes made during task execution
   
   >all calls inside a task worker always return the same context object 
instead of building new ones
   
   If I understanding correctly, the context object is updated during the task 
execution. So, when attaching the extra to the asset event, the context object 
is updated with the changes. However, in the listener, the call to the 
`get_template_context` method construct a new object and returns it. The object 
with the changes then lost, and we will never be able to get it back? So, 
adding a cache here, we can ensure all the calls to `get_template_context` is 
operating on the same context object, so the changes are persist.


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