balloob/pychromecast — pull request #30 by Raynes (2014-11-10 03:04:23+00:00)
Title: Reconnection

Reconnection/error handling, hot off the presses!

Fairly simple stuff. Only took me two days to get it done. :P

The idea is, reconnect the socket when read gets a socket exception and retry `tries` times (or forever if `tries` is None) every 5 seconds. If we can't connect in the allotted tries, set `stop` and toss one last exception. All the while this is happening, `send_message` will throw proper exceptions as to what the situation is.

As an aside, I also set `stop()` on chromecasts connected but then immediately excluded by filters. Was icky to do otherwise, because they still run in the background (I noticed while looking at exception logging and seeming them also reconnecting in the background).

Anyways, this makes pychromecast about a billion times more useful for me, so I hope you dig it!