]> kaliko git repositories - python-musicpd.git/commitdiff
mpd.py: reset to disconnected state if _hello() fails in connect()
authorJ. Alexander Treuman <jat@spatialrift.net>
Sun, 23 Mar 2008 21:07:55 +0000 (17:07 -0400)
committerJ. Alexander Treuman <jat@spatialrift.net>
Sun, 23 Mar 2008 21:07:55 +0000 (17:07 -0400)
mpd.py

diff --git a/mpd.py b/mpd.py
index ae1f2b3c349a6360127ecd06f86451432d3f453d..bd68b3cf4c4cd26d7088014de89b1509535fa7ef 100644 (file)
--- 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()