SameerMesiah97 commented on code in PR #60532:
URL: https://github.com/apache/airflow/pull/60532#discussion_r2724050485


##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py:
##########
@@ -816,48 +816,54 @@ def __init__(
         self.config_dict = config_dict
         self._extras: dict | None = connection_extras
         self._event_polling_fallback = False
+        self._config_loaded = False
 
     async def _load_config(self):
-        """Return Kubernetes API session for use with requests."""
+        """Load Kubernetes configuration once per hook instance."""
+        if self._config_loaded:
+            return

Review Comment:
   I considered that but the `@cache` decorator caches the coroutine and not 
awaited result. After the first invocation, you will run into the following 
error:
   
   `RuntimeError: cannot reuse already awaited coroutine` 
   
   That’s why I went with an explicit instance-level flag and guard here. Happy 
to clarify further if you had a different pattern in mind.



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