You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/10/28 05:24:45 UTC
(airflow) branch v3-1-test updated: [v3-1-test] fix: make _get_ssl_context_cached a static method (#57401) (#57403)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new 70bb3b076aa [v3-1-test] fix: make _get_ssl_context_cached a static method (#57401) (#57403)
70bb3b076aa is described below
commit 70bb3b076aae95bd4dd96a7170141c3feb3b6705
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Tue Oct 28 06:24:38 2025 +0100
[v3-1-test] fix: make _get_ssl_context_cached a static method (#57401) (#57403)
(cherry picked from commit 04c30dcc4e6a0899d19063cfeaf7f521b26e7695)
Co-authored-by: Wei Lee <we...@gmail.com>
---
task-sdk/src/airflow/sdk/api/client.py | 4 ++--
task-sdk/tests/task_sdk/api/test_client.py | 13 ++++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/task-sdk/src/airflow/sdk/api/client.py b/task-sdk/src/airflow/sdk/api/client.py
index 5c891c84c8f..6945c2dfbcf 100644
--- a/task-sdk/src/airflow/sdk/api/client.py
+++ b/task-sdk/src/airflow/sdk/api/client.py
@@ -814,9 +814,9 @@ API_TIMEOUT = conf.getfloat("workers", "execution_api_timeout")
class Client(httpx.Client):
- @classmethod
@lru_cache()
- def _get_ssl_context_cached(cls, ca_file: str, ca_path: str | None = None) -> ssl.SSLContext:
+ @staticmethod
+ def _get_ssl_context_cached(ca_file: str, ca_path: str | None = None) -> ssl.SSLContext:
"""Cache SSL context to prevent memory growth from repeated context creation."""
ctx = ssl.create_default_context(cafile=ca_file)
if ca_path:
diff --git a/task-sdk/tests/task_sdk/api/test_client.py b/task-sdk/tests/task_sdk/api/test_client.py
index d9c87d915c9..e73f05eeac8 100644
--- a/task-sdk/tests/task_sdk/api/test_client.py
+++ b/task-sdk/tests/task_sdk/api/test_client.py
@@ -1370,10 +1370,10 @@ class TestHITLOperations:
class TestSSLContextCaching:
- def setup_method(self):
+ @pytest.fixture(autouse=True)
+ def clear_ssl_context_cache(self):
Client._get_ssl_context_cached.cache_clear()
-
- def teardown_method(self):
+ yield
Client._get_ssl_context_cached.cache_clear()
def test_cache_hit_on_same_parameters(self):
@@ -1382,6 +1382,13 @@ class TestSSLContextCaching:
ctx2 = Client._get_ssl_context_cached(ca_file, None)
assert ctx1 is ctx2
+ def test_cache_miss_if_cache_cleared(self):
+ ca_file = certifi.where()
+ ctx1 = Client._get_ssl_context_cached(ca_file, None)
+ Client._get_ssl_context_cached.cache_clear()
+ ctx2 = Client._get_ssl_context_cached(ca_file, None)
+ assert ctx1 is not ctx2
+
def test_cache_miss_on_different_parameters(self):
ca_file = certifi.where()