{"action":"created","issue":{"url":"https://api.github.com/repos/mcrute/pydora/issues/36","labels_url":"https://api.github.com/repos/mcrute/pydora/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/mcrute/pydora/issues/36/comments","events_url":"https://api.github.com/repos/mcrute/pydora/issues/36/events","html_url":"https://github.com/mcrute/pydora/issues/36","id":121473278,"number":36,"title":"Unhandled StopIteration exception","user":{"login":"jcass77","id":10268911,"avatar_url":"https://avatars.githubusercontent.com/u/10268911?v=3","gravatar_id":"","url":"https://api.github.com/users/jcass77","html_url":"https://github.com/jcass77","followers_url":"https://api.github.com/users/jcass77/followers","following_url":"https://api.github.com/users/jcass77/following{/other_user}","gists_url":"https://api.github.com/users/jcass77/gists{/gist_id}","starred_url":"https://api.github.com/users/jcass77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcass77/subscriptions","organizations_url":"https://api.github.com/users/jcass77/orgs","repos_url":"https://api.github.com/users/jcass77/repos","events_url":"https://api.github.com/users/jcass77/events{/privacy}","received_events_url":"https://api.github.com/users/jcass77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-10T12:32:50Z","updated_at":"2015-12-13T20:18:13Z","closed_at":null,"body":"A ``StopIteration`` exception can occur on rare occasions when retrieving the next Pandora track.\r\n\r\nStack track details below:\r\n```\r\n  Received WebSocket message from 127.0.0.1: u'{\"method\":\"core.library.browse\",\"params\":[\"pandora:station:2932455179979957924:2932455179979957924\"],\"jsonrpc\":\"2.0\",\"id\":1479}'\r\nDEBUG    2015-12-10 10:17:04,778 [31248:PandoraBackend-14] pykka\r\n  Exception returned from PandoraBackend (urn:uuid:e53806cb-71bd-4cf8-b1b8-6f97bc64c7fe) to caller:\r\n```\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python2.7/site-packages/pykka/actor.py\", line 201, in _actor_loop\r\n    response = self._handle_receive(message)\r\n  File \"/usr/local/lib/python2.7/site-packages/pykka/actor.py\", line 295, in _handle_receive\r\n    return callee(*message['args'], **message['kwargs'])\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy-pandora/mopidy_pandora/library.py\", line 46, in browse\r\n    return self._browse_tracks(uri)\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy-pandora/mopidy_pandora/library.py\", line 109, in _browse_tracks\r\n    return [self.get_next_pandora_track()]\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy-pandora/mopidy_pandora/library.py\", line 138, in get_next_pandora_track\r\n    pandora_track = self._station_iter.next()\r\nStopIteration\r\n```\r\n```\r\nERROR    2015-12-10 10:17:04,783 [31248:Core-16] mopidy.core.library\r\n  PandoraBackend backend caused an exception.\r\n```\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy/mopidy/core/library.py\", line 19, in _backend_error_handling\r\n    yield\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy/mopidy/core/library.py\", line 112, in _browse\r\n    result = backend.library.browse(uri).get()\r\n  File \"/usr/local/lib/python2.7/site-packages/pykka/threading.py\", line 52, in get\r\n    compat.reraise(*self._data['exc_info'])\r\n  File \"/usr/local/lib/python2.7/site-packages/pykka/compat.py\", line 12, in reraise\r\n    exec('raise tp, value, tb')\r\n  File \"/usr/local/lib/python2.7/site-packages/pykka/actor.py\", line 201, in _actor_loop\r\n    response = self._handle_receive(message)\r\n  File \"/usr/local/lib/python2.7/site-packages/pykka/actor.py\", line 295, in _handle_receive\r\n    return callee(*message['args'], **message['kwargs'])\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy-pandora/mopidy_pandora/library.py\", line 46, in browse\r\n    return self._browse_tracks(uri)\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy-pandora/mopidy_pandora/library.py\", line 109, in _browse_tracks\r\n    return [self.get_next_pandora_track()]\r\n  File \"/Users/jcass/PycharmProjects/Mopidy/mopidy-pandora/mopidy_pandora/library.py\", line 138, in get_next_pandora_track\r\n    pandora_track = self._station_iter.next()\r\nStopIteration\r\n```\r\n```\r\nDEBUG    2015-12-10 10:17:10,338 [31248:HttpServer] mopidy.http.handlers\r\n  Sent WebSocket message to 127.0.0.1: '{\"jsonrpc\": \"2.0\", \"id\": 1479, \"result\": []}'\r\n```\r\n\r\nThis is supposed to be handled by [`stop_iteration`](https://github.com/mcrute/pydora/blob/dbc3e7a5b1809bbf809bc7abc82913fc8bc90533/pydora/utils.py#L111-L123), so not sure what the root cause is."},"comment":{"url":"https://api.github.com/repos/mcrute/pydora/issues/comments/164294703","html_url":"https://github.com/mcrute/pydora/issues/36#issuecomment-164294703","issue_url":"https://api.github.com/repos/mcrute/pydora/issues/36","id":164294703,"user":{"login":"mcrute","id":108204,"avatar_url":"https://avatars.githubusercontent.com/u/108204?v=3","gravatar_id":"","url":"https://api.github.com/users/mcrute","html_url":"https://github.com/mcrute","followers_url":"https://api.github.com/users/mcrute/followers","following_url":"https://api.github.com/users/mcrute/following{/other_user}","gists_url":"https://api.github.com/users/mcrute/gists{/gist_id}","starred_url":"https://api.github.com/users/mcrute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcrute/subscriptions","organizations_url":"https://api.github.com/users/mcrute/orgs","repos_url":"https://api.github.com/users/mcrute/repos","events_url":"https://api.github.com/users/mcrute/events{/privacy}","received_events_url":"https://api.github.com/users/mcrute/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T20:18:12Z","updated_at":"2015-12-13T20:18:12Z","body":"I tried to reproduce this but haven't had much luck, do you know what conditions this happens under? I tried a fake test and the only way I was able to reproduce the issues was if the wrapped function throws a `StopIteration` error when `iterate_forever` tries to refresh it's internal iterator. It would be possible to catch `StopIteration` a second time when refreshing the iterator but I'd like to reproduce this to find the root cause first.\r\n\r\nYour Mopidy-Pandora code looks correct as far as I can tell."}}