From: J. Alexander Treuman Date: Sun, 23 Mar 2008 21:07:55 +0000 (-0400) Subject: mpd.py: reset to disconnected state if _hello() fails in connect() X-Git-Tag: v0.2.0~5 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=202767471f017c54d1ba73e2ad4bedca5ef0d40f;p=python-musicpd.git mpd.py: reset to disconnected state if _hello() fails in connect() --- diff --git a/mpd.py b/mpd.py index ae1f2b3..bd68b3c 100644 --- a/mpd.py +++ b/mpd.py @@ -307,7 +307,11 @@ class MPDClient(object): raise socket.error, msg self._rfile = self._sock.makefile("rb") self._wfile = self._sock.makefile("wb") - self._hello() + try: + self._hello() + except (socket.error, MPDError): + self.disconnect() + raise def disconnect(self): self._rfile.close()