Review
Watchlist bids filled by completion order
PR: Speed up the live auction watchlist endpoint. Instead of awaiting lot high-bids serially, fan out HTTP calls with asyncio and collect via as_completed so slow lots no longer block the whole card. Response shape is still List[BidSnapshot] aligned 1:1 with the requested lot_ids so the mobile client can zip them without a map.
asyncioTier 4asyncioas_completedorderingfan-out
Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.
services/auction_api/watchlist_bids.py+6-4
| 41 | 41 | async def load_watchlist_bids( | |
| 42 | 42 | session: aiohttp.ClientSession, | |
| 43 | 43 | lot_ids: Sequence[str], | |
| 44 | 44 | ) -> list[BidSnapshot]: | |
| 45 | 45 | """Return current high-bid snapshot per lot_id, same order as input.""" | |
| 46 | - | snapshots: list[BidSnapshot] = [] | |
| 47 | - | for lot_id in lot_ids: | |
| 48 | - | snapshots.append(await fetch_high_bid(session, lot_id)) | |
| 49 | - | return snapshots | |
| 46 | + | tasks = [fetch_high_bid(session, lot_id) for lot_id in lot_ids] | |
| 47 | + | snapshots: list[BidSnapshot] = [] | |
| 48 | + | # Drain as each HTTP call finishes so slow lots don't stall the rest. | |
| 49 | + | for finished in asyncio.as_completed(tasks): | |
| 50 | + | snapshots.append(await finished) | |
| 51 | + | return snapshots |