deejcunningham / skill-score

Deprecated Mycroft skill to report latest MLB scores
MIT License
3 stars 5 forks source link

Socket timeout #1

Closed deejcunningham closed 6 years ago

deejcunningham commented 6 years ago

When used in Mycroft, the skill fails. Requests can be made outside of Mycroft's virtualenvironment successfully and the skill actually runs successfully maybe ~10% of the time within Mycroft. The following error pops up:

17:26:29.948 - mycroft.skills.core:wrapper:607 - ERROR - An error occurred while processing a request in Score Skill
Traceback (most recent call last):
File "/home/dj/mycroft-core/mycroft/skills/core.py", line 598, in wrapper
handler(message)
File "/opt/mycroft/skills/skill-score/__init__.py", line 103, in handle_live_score_intent
self.get_result()
File "/opt/mycroft/skills/skill-score/__init__.py", line 76, in get_result
self.get_game()
File "/opt/mycroft/skills/skill-score/__init__.py", line 58, in get_game
self.game = mlbgame.day(self.year, self.month, self.day, home=self.team, away=self.team)
File "/home/dj/mycroft-core/.venv/lib/python3.6/site-packages/mlbgame/__init__.py", line 151, in day
data = mlbgame.game.scoreboard(year, month, day, home=home, away=away)
File "/home/dj/mycroft-core/.venv/lib/python3.6/site-packages/mlbgame/game.py", line 19, in scoreboard
data = mlbgame.data.get_scoreboard(year, month, day)
File "/home/dj/mycroft-core/.venv/lib/python3.6/site-packages/mlbgame/data.py", line 49, in get_scoreboard
data = urlopen(BASE_URL.format(year, month, day) + 'scoreboard.xml')
File "/home/dj/miniconda3/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/home/dj/miniconda3/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/home/dj/miniconda3/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/home/dj/miniconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/home/dj/miniconda3/lib/python3.6/urllib/request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/home/dj/miniconda3/lib/python3.6/urllib/request.py", line 1321, in do_open
r = h.getresponse()
File "/home/dj/miniconda3/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/home/dj/miniconda3/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/home/dj/miniconda3/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/home/dj/miniconda3/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
deejcunningham commented 6 years ago

Currently testing after having left Mycroft running in background for some time and most scores are fetched immediately and without error. Testing in the evening with only one in-progress game so most of the scores may be cached by mlbgame

deejcunningham commented 6 years ago

Currently worked-around by setting default socket timeout to 100 seconds. Thanks to @forslund at Mycroft for investigating.