Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest): respect rest emitter timeout setting #5508

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions metadata-ingestion/src/datahub/emitter/rest_emitter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import functools
import json
import logging
from json.decoder import JSONDecodeError
Expand Down Expand Up @@ -130,6 +131,13 @@ def __init__(
self._session.mount("http://", adapter)
self._session.mount("https://", adapter)

# Shim session.request to apply default timeout values.
# Via https://stackoverflow.com/a/59317604.
self._session.request = functools.partial( # type: ignore
self._session.request,
timeout=(self._connect_timeout_sec, self._read_timeout_sec),
)

def test_connection(self) -> dict:
response = self._session.get(f"{self._gms_server}/config")
if response.status_code == 200:
Expand Down Expand Up @@ -226,12 +234,7 @@ def _emit_generic(self, url: str, payload: str) -> None:
curl_command,
)
try:
response = self._session.post(
url,
data=payload,
timeout=(self._connect_timeout_sec, self._read_timeout_sec),
)

response = self._session.post(url, data=payload)
response.raise_for_status()
except HTTPError as e:
try:
Expand Down