line = self._rfile.readline()
if not line.endswith("\n"):
raise ConnectionError, "Connection lost while reading MPD hello"
+ line = line.rstrip("\n")
if not line.startswith(HELLO_PREFIX):
raise ProtocolError, "Got invalid MPD hello: '%s'" % line
self.mpd_version = line[len(HELLO_PREFIX):].strip()
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()