Skip to content

Commit 7bb4cd5

Browse files
authored
fix: delayed response because of synced request call (#45)
* fix: delayed response because of synced request call * fix: Catch HTTPStatusError
1 parent 3f6ed1d commit 7bb4cd5

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

application/service/provider_status_service.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import requests
1+
import httpx
22
import urllib3
33

44
from application.config.config import Config
@@ -17,9 +17,10 @@ async def check_provider_online_status_v2(chain_id: str, provider_uri: str):
1717
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
1818

1919
try:
20-
response = requests.get(f"{provider_uri}/status", verify=False, timeout=20)
21-
response.raise_for_status()
22-
return response.json()
23-
except requests.exceptions.RequestException as e:
20+
async with httpx.AsyncClient(verify=False, timeout=20.0) as client:
21+
response = await client.get(f"{provider_uri}/status")
22+
response.raise_for_status()
23+
return response.json()
24+
except (httpx.RequestError, httpx.TimeoutException, httpx.HTTPStatusError) as e:
2425
log.error(f"Error checking provider online status v2: {e}")
2526
return False

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ fabric==3.2.2
77
requests==2.32.3
88
pyjwt==2.9.0
99
redis==4.5.4
10-
packaging==24.2
10+
packaging==24.2
11+
httpx==0.28.1

0 commit comments

Comments
 (0)