gsavin commited on
Commit
7150fb6
·
1 Parent(s): f8bbabf

fix: take request timeout from config

Browse files
Files changed (1) hide show
  1. src/agent/utils.py +4 -2
src/agent/utils.py CHANGED
@@ -4,6 +4,8 @@ import asyncio
4
  import logging
5
  from typing import Awaitable, Callable, TypeVar
6
 
 
 
7
  logger = logging.getLogger(__name__)
8
 
9
  T = TypeVar("T")
@@ -12,7 +14,7 @@ T = TypeVar("T")
12
  async def with_retries(
13
  awaitable_factory: Callable[[], Awaitable[T]],
14
  retries: int = 3,
15
- timeout: int = 15,
16
  ) -> T:
17
  """Execute an awaitable with retries and timeout.
18
 
@@ -26,6 +28,6 @@ async def with_retries(
26
  try:
27
  return await asyncio.wait_for(awaitable_factory(), timeout=timeout)
28
  except Exception as e:
29
- logger.warning(f"Attempt {attempt + 1}/{retries} failed with error: {e}")
30
  last_exception = e
31
  raise last_exception from last_exception
 
4
  import logging
5
  from typing import Awaitable, Callable, TypeVar
6
 
7
+ from src.config import settings
8
+
9
  logger = logging.getLogger(__name__)
10
 
11
  T = TypeVar("T")
 
14
  async def with_retries(
15
  awaitable_factory: Callable[[], Awaitable[T]],
16
  retries: int = 3,
17
+ timeout: int = settings.request_timeout,
18
  ) -> T:
19
  """Execute an awaitable with retries and timeout.
20
 
 
28
  try:
29
  return await asyncio.wait_for(awaitable_factory(), timeout=timeout)
30
  except Exception as e:
31
+ logger.warning(f"Attempt {attempt + 1}/{retries} failed with error: {str(e)}")
32
  last_exception = e
33
  raise last_exception from last_exception