feat: add explicit 30 second timeout for Bitfinex API requests
Previously used httpx's implicit default (5 seconds). Explicit timeout makes behavior clear and gives more time for slow responses.
This commit is contained in:
parent
ec835a2935
commit
1c9761e559
1 changed files with 3 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import httpx
|
|||
|
||||
BITFINEX_TICKER_URL = "https://api-pub.bitfinex.com/v2/ticker/tBTCEUR"
|
||||
LAST_PRICE_INDEX = 6
|
||||
REQUEST_TIMEOUT_SECONDS = 30.0
|
||||
|
||||
# Constants for price history records
|
||||
SOURCE_BITFINEX = "bitfinex"
|
||||
|
|
@ -21,10 +22,10 @@ async def fetch_btc_eur_price() -> tuple[float, datetime]:
|
|||
|
||||
Raises:
|
||||
httpx.HTTPStatusError: If the API returns a non-2xx status code.
|
||||
httpx.RequestError: If a network error occurs.
|
||||
httpx.RequestError: If a network error occurs (including timeout).
|
||||
ValueError: If the response format is unexpected.
|
||||
"""
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT_SECONDS) as client:
|
||||
response = await client.get(BITFINEX_TICKER_URL)
|
||||
response.raise_for_status()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue