mirror of
https://github.com/beetbox/beets.git
synced 2026-01-07 00:15:20 +01:00
catch MB BadStatusLine errors
This commit is contained in:
parent
4b5c674d9b
commit
2e2c1be1bd
2 changed files with 8 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ import re
|
|||
import time
|
||||
import logging
|
||||
import musicbrainz2.webservice as mbws
|
||||
import httplib
|
||||
from musicbrainz2.model import Release
|
||||
from threading import Lock
|
||||
from musicbrainz2.model import VARIOUS_ARTISTS_ID
|
||||
|
|
@ -93,6 +94,8 @@ def _query_wrap(fun, *args, **kwargs):
|
|||
# Malformed response from server.
|
||||
log.error('Bad response from MusicBrainz: ' + str(exc))
|
||||
raise BadResponseError()
|
||||
except httplib.BadStatusLine:
|
||||
log.warn('Bad HTTP status line from MusicBrainz')
|
||||
except mbws.WebServiceError, e:
|
||||
# Server busy. Retry.
|
||||
message = str(e.reason)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import unittest
|
|||
import time
|
||||
import musicbrainz2.model
|
||||
import musicbrainz2.webservice as mbws
|
||||
import httplib
|
||||
|
||||
import _common
|
||||
from beets.autotag import mb
|
||||
|
|
@ -85,6 +86,10 @@ class MBQueryErrorTest(unittest.TestCase):
|
|||
exc = mbws.WebServiceError(reason=Exception('Error 504'))
|
||||
mb._query_wrap(raise_once_func(exc))
|
||||
|
||||
def test_status_line_error_retries(self):
|
||||
exc = httplib.BadStatusLine('dummy')
|
||||
mb._query_wrap(raise_once_func(exc))
|
||||
|
||||
def test_999_error_passes_through(self):
|
||||
exc = mbws.WebServiceError(reason=Exception('Error 999'))
|
||||
with self.assertRaises(mbws.WebServiceError):
|
||||
|
|
|
|||
Loading…
Reference in a new issue