Overview
Replace blocking requests.get() with async HTTP client in rate_limited_request() function.
Identified by: Copilot PR review on #7
Problem
The rate_limited_request() function is declared as async but uses the blocking requests.get() call, which can block the event loop and hurt performance.
File Affected
src/api.py:139 in rate_limited_request()
Current Code
async def rate_limited_request(url: str, max_retries: int = 3, base_delay: float = 1.0) -> requests.Response:
# ...
response = requests.get(url, timeout=10) # ❌ Blocking call in async function
# ...
Solution Options
- Use aiohttp (recommended - already a dependency)
- Use asyncio.to_thread() to offload to thread pool
- Use httpx (would need new dependency)
Recommended Implementation
import aiohttp
async def rate_limited_request(url: str, max_retries: int = 3, base_delay: float = 1.0) -> aiohttp.ClientResponse:
async with aiohttp.ClientSession() as session:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=10)) as response:
# ... existing logic
Impact
- Performance: Prevents event loop blocking
- Scalability: Better handling of concurrent requests
- Architecture: Maintains true async behavior throughout
Acceptance Criteria
Priority
Medium - Performance improvement, not a critical bug.
Related to linting infrastructure work but separate architectural concern.
Overview
Replace blocking
requests.get()with async HTTP client inrate_limited_request()function.Identified by: Copilot PR review on #7
Problem
The
rate_limited_request()function is declared asasyncbut uses the blockingrequests.get()call, which can block the event loop and hurt performance.File Affected
src/api.py:139inrate_limited_request()Current Code
Solution Options
Recommended Implementation
Impact
Acceptance Criteria
requests.get()withaiohttpPriority
Medium - Performance improvement, not a critical bug.
Related to linting infrastructure work but separate architectural concern.