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/02/17 19:00:16 UTC

[GitHub] [airflow] josh-fell commented on a change in pull request #21527: Update Airflow connection object to a `cached_property` in `HttpHook`

josh-fell commented on a change in pull request #21527:
URL: https://github.com/apache/airflow/pull/21527#discussion_r809372501



##########
File path: airflow/providers/http/hooks/http.py
##########
@@ -54,6 +60,10 @@ def __init__(
         self._retry_obj: Callable[..., Any]
         self.auth_type: Any = auth_type
 
+    @cached_property
+    def conn(self):
+        return self.get_connection(self.http_conn_id)

Review comment:
       Yeah I've thought about that, but I had some trouble playing around/figuring out how to cache a `classmethod` result although I didn't spend a _ton_ of time on it. There were some existing unit tests that would fail and didn't get the change to figure out if the test was correct and the implementation was wrong or vice versa.
   
   I agree the caching feels like it's better in `BaseHook`. I can certainly revisit this though.




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