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

Crash on HTTP 502 response #8

Closed
dowski opened this issue Aug 10, 2020 · 0 comments
Closed

Crash on HTTP 502 response #8

dowski opened this issue Aug 10, 2020 · 0 comments

Comments

@dowski
Copy link
Owner

dowski commented Aug 10, 2020

I think that the new StatsAPI based scoreboard code isn't handling failed HTTP requests properly.

Aug  9 20:54:03 scoreboard2 scoreboard[4695]: Traceback (most recent call last):
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/home/pi/deploy/env/bin/scoreboard", line 11, in <module>
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     load_entry_point('dowski.scoreboard', 'console_scripts', 'scoreboard')()
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/home/pi/deploy/scoreboard/scoreboard/scoreboard.py", line 47, in start
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     main(sys.argv)
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/home/pi/deploy/scoreboard/scoreboard/scoreboard.py", line 67, in main
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     jobs.run()
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/usr/lib/python3.7/sched.py", line 151, in run
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     action(*argument, **kwargs)
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/home/pi/deploy/scoreboard/scoreboard/tracker.py", line 55, in track
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     game_details = self.mlbapi.get_game_detail(scheduled_game.game_id)
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/home/pi/deploy/scoreboard/scoreboard/mlb.py", line 72, in get_game_detail
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     response = statsapi.get('game', {'gamePk':game_id, 'fields':"gameData,teams,teamName,status,detailedState,liveData,linescore,home,away,runs,hits,errors,offense,outs,balls,strikes,first,second,third,currentInning,inningState"})
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:   File "/home/pi/deploy/env/lib/python3.7/site-packages/MLB_StatsAPI-0.1.9-py3.7.egg/statsapi/__init__.py", line 1644, in get
Aug  9 20:54:03 scoreboard2 scoreboard[4695]:     raise ValueError("Request failed. Status Code: " + str(r.status_code) + ".")
Aug  9 20:54:03 scoreboard2 scoreboard[4695]: ValueError: Request failed. Status Code: 502.

I guess I need to handle ValueError here, although that seems like a broad exception to catch. Maybe I can submit a change upstream in StatsAPI that indicates more clearly that the error is at the HTTP level.

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

No branches or pull requests

1 participant