diff --git a/beetsplug/echonest_tempo.py b/beetsplug/echonest_tempo.py index f93842e38..467dcb75d 100644 --- a/beetsplug/echonest_tempo.py +++ b/beetsplug/echonest_tempo.py @@ -71,16 +71,20 @@ def get_tempo(artist, title): ) except pyechonest.util.EchoNestAPIError as e: if e.code == 3: - # Rate limit exceeded. - if i >= RETRIES - 1: - # Waited too many times already. - log.debug(u'echonest_tempo: exceeded retries') - return None - else: - # Wait and try again. - time.sleep(RETRY_INTERVAL) + # Wait and try again. + time.sleep(RETRY_INTERVAL) + else: + raise + except pyechonest.util.EchoNestIOError as e: + log.debug(u'echonest_tempo: IO error: {0}'.format(e)) + time.sleep(RETRY_INTERVAL) else: break + else: + # If we exited the loop without breaking, then we used up all + # our allotted retries. + log.debug(u'echonest_tempo: exceeded retries') + return None if len(results) > 0: return results[0].audio_summary['tempo'] diff --git a/docs/changelog.rst b/docs/changelog.rst index b4a74770e..4305f8e35 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,8 +4,9 @@ Changelog 1.0rc2 (in development) ----------------------- -* :doc:`/plugins/echonest_tempo`: If the Echo Nest API limit is exceeded, the - plugin now waits and tries again instead of crashing. Thanks to Zach Denton. +* :doc:`/plugins/echonest_tempo`: If the Echo Nest API limit is exceeded or a + communication error occurs, the plugin now waits and tries again instead of + crashing. Thanks to Zach Denton. * :doc:`/plugins/fetchart`: Fix a regression that caused crashes when art was not available from some sources. * Fix a regression on Windows that caused all relative paths to be "not found".