Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout Error. Do I condense my code or make other calls? #364

Closed
willyamwu opened this issue Aug 19, 2023 · 2 comments
Closed

Timeout Error. Do I condense my code or make other calls? #364

willyamwu opened this issue Aug 19, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@willyamwu
Copy link

Firstly, this api wrapper is wonderful and provides so much vital information. Thank you to all who have worked on it!

I keep running into this timeout error (shown below) and based on looking at some previous issues, it might be because my code is pulling from the api too much. Here is the rough rundown of my code and the endpoints I am using. I'm wondering if I'm calling too much or there is some other issue.

  1. I'm pulling the current games that are happening on a certain date. LeagueGameFinder(date_from_nullable=yesterday_date_string, date_to_nullable=yesterday_date_string, league_id_nullable='00')
  2. I'm getting the list of players that played in the game. BoxScoreTraditionalV2(game_id=game_id)
  3. Getting their names. players.find_player_by_id(player)['full_name'], ": N/A"
  4. Using BoxScoreSummaryV2(game_id=game_id) and connecting it to the game ids I had earlier to get the full names of the teams playing.

Since there are a lot of games that can go on in a day and a lot of players there can be 100+ calls I think. Is there an endpoint that gives you this information faster?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/williamwu/Sterdy/nba-twitter.py", line 200, in <module>
    get_games() 
  File "/Users/williamwu/Sterdy/nba-twitter.py", line 49, in get_games
    gamelog = endpoints.PlayerGameLog(player_id=player, date_to_nullable=yesterday_date_string, date_from_nullable=yesterday_date_string)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nba_api/stats/endpoints/playergamelog.py", line 40, in __init__
    self.get_request()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nba_api/stats/endpoints/playergamelog.py", line 43, in get_request
    self.nba_response = NBAStatsHTTP().send_api_request(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nba_api/library/http.py", line 130, in send_api_request
    response = requests.get(url=base_url, params=parameters, headers=request_headers, proxies=proxies, timeout=timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='stats.nba.com', port=443): Read timed out. (read timeout=30)
@rsforbes
Copy link
Collaborator

@willyamwu - Take a look at this issue: #176

@rsforbes rsforbes added the duplicate This issue or pull request already exists label Aug 19, 2023
@rsforbes
Copy link
Collaborator

Duplicate #176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants