Skip to content

Commit

Permalink
handle ClientConnectionError in HttpAsyncHook
Browse files Browse the repository at this point in the history
  • Loading branch information
sungwy committed Feb 14, 2023
1 parent e43d3f7 commit b6ba1cc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion airflow/providers/http/hooks/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import aiohttp
import requests
import tenacity
from aiohttp import ClientResponseError
from aiohttp import ClientConnectionError, ClientResponseError
from asgiref.sync import sync_to_async
from requests.auth import HTTPBasicAuth
from requests_toolbelt.adapters.socket_options import TCPKeepAliveAdapter
Expand Down Expand Up @@ -371,6 +371,16 @@ async def run(
try:
response.raise_for_status()
return response
except ClientConnectionError as e:
self.log.warning(
"[Try %d of %d] Request to %s failed.",
attempt_num,
self.retry_limit,
url,
)
if attempt_num == self.retry_limit:
self.log.exception(str(e))
raise AirflowException(str(e))
except ClientResponseError as e:
self.log.warning(
"[Try %d of %d] Request to %s failed.",
Expand Down

0 comments on commit b6ba1cc

Please sign in to comment.