Closed GoogleCodeExporter closed 9 years ago
I can't debug this issue. Please only submit issues with code that reproduces
it.
Original comment by amr.hassan
on 21 Jan 2011 at 8:35
Actually, I did have full logging turned on. The code that was executed was
approximately this:
network.update_now_playing(
u'Massive Attack',
u'Pray For Rain',
album=u'Heligoland',
duration='404',
track_number='1',
mbid='')
Original comment by stein.ma...@jodal.no
on 21 Jan 2011 at 8:37
Can you still reproduce the issue with that code? Because I just ran it on
python 2.7 and it ran fine with no errors.
Original comment by amr.hassan
on 21 Jan 2011 at 8:42
Sorry, but I can't ensure that Last.fm always behaves identically.
You are though in the position of catching and wrapping these exceptions, so I,
as a user of your library, does not have to worry about the exceptions each and
every library you use could raise. Doing that for all libraries I use and their
libraries again would quite fast become rather tedious and infeasible.
Original comment by stein.ma...@jodal.no
on 21 Jan 2011 at 8:47
It's in The Zen of Python that "Errors should never pass silently."
(http://www.python.org/dev/peps/pep-0020/).
Your code should be prepared however to catch exceptions resulting from network
data corruption or funky last.fm responses and retrying or ignoring the request
based on your liking.
Original comment by amr.hassan
on 21 Jan 2011 at 8:54
Of course they should not pass silently. And of course I should take care and
perform proper actions upon such events.
Still, wrapping exceptions does not silence them. It just means that I can
catch one well-known exception related to intermittent problems like network
outages and handle that with care.
The alternative is that all users of the library will detect all the possible
error conditions over time and will have to catch each and every one of them
themselves. Not to mention the fact that new possible exceptions could be
introduced by the library developer introducing new dependencies with new
exceptions himself.
Or do you want me to "except Exception:"?
Original comment by stein.ma...@jodal.no
on 21 Jan 2011 at 9:00
You can catch the well known exceptions and also finally catch any other
unknown exception as well in areas where you see that can produce unknown
exceptions like so:
try:
#code
except pylast.WSError:
# handle that error
except Exception as e:
# Handle any other errors too.
I will look into handling malformed responses from Last.fm and raising one
single exception for that if that's what you're proposing.
Original comment by amr.hassan
on 21 Jan 2011 at 9:13
Yes, that would be lovely! :-)
This far, I've gotten the following exceptions from Pylast upon
connection/response problems:
- UnicodeDecodeError
- socket.error
- xml.parsers.expat.ExpatError
- httplib.HTTPException
Original comment by stein.ma...@jodal.no
on 21 Jan 2011 at 9:16
Err, I've got httplib.BadStatusLine, which is a subclass of
httplib.HTTPException.
Original comment by stein.ma...@jodal.no
on 21 Jan 2011 at 9:17
Stacktrace from the httplib error:
...
File "/home/jodal/dev/mopidy/mopidy/frontends/lastfm.py", line 78, in setup
username=username, password_hash=password_hash)
File "/usr/lib/pymodules/python2.6/pylast.py", line 572, in __init__
"user": "user/%(name)s",
File "/usr/lib/pymodules/python2.6/pylast.py", line 161, in __init__
self.session_key = sk_gen.get_session_key(self.username, self.password_hash)
File "/usr/lib/pymodules/python2.6/pylast.py", line 898, in get_session_key
doc = request.execute()
File "/usr/lib/pymodules/python2.6/pylast.py", line 801, in execute
response = self._download_response()
File "/usr/lib/pymodules/python2.6/pylast.py", line 790, in _download_response
response = conn.getresponse()
File "/usr/lib/python2.6/httplib.py", line 990, in getresponse
response.begin()
File "/usr/lib/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
raise BadStatusLine(line)
BadStatusLine
I guess this is a good day for testing connection issues with Last.fm:
http://blog.last.fm/2011/01/21/about-the-last-24-hours
Original comment by stein.ma...@jodal.no
on 21 Jan 2011 at 9:20
Okay, keep the stracktraces coming.
Original comment by amr.hassan
on 21 Jan 2011 at 9:39
This issue was closed by revision r242.
Original comment by amr.hassan
on 21 Jan 2011 at 9:49
Original issue reported on code.google.com by
stein.ma...@jodal.no
on 21 Jan 2011 at 8:29