Skip to content

Commit

Permalink
Change httpx to requests in file_task_handler
Browse files Browse the repository at this point in the history
- httpx does not support CIDRs in NO_PROXY
- simply, convert httpx to requests, issues done
- related issue: #39794
  • Loading branch information
scott-py authored and eladkal committed Jun 9, 2024
1 parent 14a613f commit 7466f57
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions airflow/utils/log/file_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _set_task_deferred_context_var():

def _fetch_logs_from_service(url, log_relative_path):
# Import occurs in function scope for perf. Ref: https://github.com/apache/airflow/pull/21438
import httpx
import requests

from airflow.utils.jwt_signer import JWTSigner

Expand All @@ -96,7 +96,7 @@ def _fetch_logs_from_service(url, log_relative_path):
expiration_time_in_seconds=conf.getint("webserver", "log_request_clock_grace", fallback=30),
audience="task-instance-logs",
)
response = httpx.get(
response = requests.get(
url,
timeout=timeout,
headers={"Authorization": signer.generate_signed_token({"filename": log_relative_path})},
Expand Down Expand Up @@ -574,9 +574,9 @@ def _read_from_logs_server(self, ti, worker_log_rel_path) -> tuple[list[str], li
messages.append(f"Found logs served from host {url}")
logs.append(response.text)
except Exception as e:
from httpx import UnsupportedProtocol
from requests.exceptions import InvalidSchema

if isinstance(e, UnsupportedProtocol) and ti.task.inherits_from_empty_operator is True:
if isinstance(e, InvalidSchema) and ti.task.inherits_from_empty_operator is True:
messages.append(self.inherits_from_empty_operator_log_message)
else:
messages.append(f"Could not read served logs: {e}")
Expand Down

0 comments on commit 7466f57

Please sign in to comment.