Skip to content

Commit

Permalink
Added timeout for requests
Browse files Browse the repository at this point in the history
  • Loading branch information
wleong1 committed Mar 7, 2024
1 parent a6e9e65 commit 8c24a11
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
- name: Install Dependencies
run: |
pip install mypy
mypy src --install-types
- name: mypy
run: |
mypy src/
Expand Down Expand Up @@ -71,7 +70,7 @@ jobs:
python-version: 3.x
- name: Install Dependencies
run: |
pip install pytest requests pandas
pip install pytest requests pandas yfinance
- name: pytest
run: |
pytest tests/
3 changes: 2 additions & 1 deletion src/live_price_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def display_final_price_av(company_name: str) -> Union[str, dict, Any]:
"symbol": company_name,
}
price_response: requests.models.Response = requests.get(
ALPHA_VANTAGE_ENDPOINT, params=price_params
ALPHA_VANTAGE_ENDPOINT, params=price_params,
timeout=20
)
if price_response.ok:
response_data: dict = price_response.json()
Expand Down
3 changes: 2 additions & 1 deletion src/news_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def _collect_news(company_name: str) -> list:
news_params: dict = {"apiKey": NEWS_API_KEY, "qInTitle": company_name}

news_response: requests.models.Response = requests.get(
NEWS_ENDPOINT, params=news_params
NEWS_ENDPOINT, params=news_params,
timeout=20
)
articles: list = news_response.json()["articles"]
five_articles: list = articles[:5]
Expand Down

0 comments on commit 8c24a11

Please sign in to comment.