Skip to content

Commit

Permalink
fix(ingest): respect rest emitter timeout setting
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 committed Jul 27, 2022
1 parent 9b5afcc commit 903271c
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit 903271c

Please sign in to comment.