Skip to content

refactor: use run_in_threadpool for asset service calls in watchlist router#220

Merged
vcfgv merged 1 commit intomainfrom
performance/watchlist-route-run-in-threadpool
Oct 28, 2025
Merged

refactor: use run_in_threadpool for asset service calls in watchlist router#220
vcfgv merged 1 commit intomainfrom
performance/watchlist-route-run-in-threadpool

Conversation

@vcfgv
Copy link
Collaborator

@vcfgv vcfgv commented Oct 28, 2025

📝 Pull Request Template

1. Related Issue

Closes #219

Type of Change (select one)

Performance

3. Description

Wrapped blocking service calls in the watchlist router with Starlette’s run_in_threadpool to avoid event-loop blocking caused by synchronous underlying libraries (e.g., yfinance).
Added the import and updated these async routes:

  • GET /asset/search
  • GET /asset/{ticker}
  • GET /asset/{ticker}/price
  • GET /{watchlist_name}
  • GET /asset/{ticker}/price/historical.

4. Testing

  • I have tested this locally.
  • I have updated or added relevant tests.

5. Checklist

@vcfgv vcfgv requested review from DigHuang and hazeone October 28, 2025 09:43
@vcfgv vcfgv merged commit 5692b27 into main Oct 28, 2025
3 checks passed
@vcfgv vcfgv deleted the performance/watchlist-route-run-in-threadpool branch October 28, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watchlist router missing async methods, blocking I/O

2 participants