yahoo_fantasy_api icon indicating copy to clipboard operation
yahoo_fantasy_api copied to clipboard

Getting RuntimeError every now and then in various fashions

Open KipFeher85 opened this issue 4 years ago • 2 comments

Have you discovered if there is a rate limit? I don't know why I keep getting this error nor why I should be getting it. I do not believe it is a problem with my code since it does work as intended the majority of the time

Console log:

[2021-06-10 19:09:46,284 DEBUG] [yahoo_oauth.oauth.__init__] Checking 
[2021-06-10 19:09:46,284 DEBUG] [yahoo_oauth.oauth.token_is_valid] ELAPSED TIME : 1270.8750066757202
[2021-06-10 19:09:46,284 DEBUG] [yahoo_oauth.oauth.token_is_valid] TOKEN IS STILL VALID
Traceback (most recent call last):
  File "C:/Users/kipfe/PycharmProjects/FantasyBaseball/main.py", line 385, in <module>
    getAllPlayers("season", 0)
  File "C:/Users/kipfe/PycharmProjects/FantasyBaseball/main.py", line 326, in getAllPlayers
    takenPitchers = getPitchers(type, 1)
  File "C:/Users/kipfe/PycharmProjects/FantasyBaseball/main.py", line 237, in getPitchers
    pitcherStats = lg.player_stats(allPID[i], req_type=type)
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\league.py", line 687, in player_stats
    stats += self._fetch_plyr_stats(game_code, next_player_ids,
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\league.py", line 778, in _fetch_plyr_stats
    json = self.yhandler.get_player_stats_raw(game_code, player_ids,
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\yhandler.py", line 311, in get_player_stats_raw
    return self.get(uri)
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\yhandler.py", line 25, in get
    raise RuntimeError(response.content)
RuntimeError: b'Request denied\r\n'

My league object:

from yahoo_oauth import OAuth2
import yahoo_fantasy_api as yfa

oAuth = OAuth2(None, None, from_file='OAuth2.json')

gm = yfa.Game(oAuth, 'mlb')

lg = gm.to_league('404.l.15530')
tmK = lg.team_key()
tm = lg.to_team(team_key=tmK)

KipFeher85 avatar Jun 10 '21 23:06 KipFeher85

I’ve seen this occasionally too. Retrying the command always seems to work though. It may be helpful to have retry logic built into the yahoo_fantasy_api to handle this.

spilchen avatar Jun 14 '21 01:06 spilchen

Yeah its very strange. A lot of the time it seems that my lg.team_key() is what triggers the error such as:

Traceback (most recent call last):
  File "C:/Users/kipfe/PycharmProjects/FantasyBaseball/main.py", line 11, in <module>
    tmK = lg.team_key()
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\league.py", line 207, in team_key
    t = objectpath.Tree(self.yhandler.get_teams_raw())
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\yhandler.py", line 68, in get_teams_raw
    return self.get("users;use_login=1/games/teams")
  File "C:\Users\kipfe\PycharmProjects\FantasyBaseball\venv\lib\site-packages\yahoo_fantasy_api\yhandler.py", line 25, in get
    raise RuntimeError(response.content)
RuntimeError: b'Request denied\r\n'](url)

KipFeher85 avatar Jun 14 '21 20:06 KipFeher85