'Receives a message from the control socket, blocking until we\'ve received
one. For more information see the :func:`~stem.socket.recv_message` function.
:returns: :class:`~stem.response.ControlMessage` for the message received
:raises:
* :class:`stem.ProtocolError` the content from the socket is malformed
* :class:`stem.SocketClosed` if the socket closes before we receive a complete message'

def recv(self):

    with self._recv_lock:
        try:
            socket_file = self._socket_file
            if (not socket_file):
                raise stem.SocketClosed()
            return recv_message(socket_file)
        except stem.SocketClosed as exc:
            if self.is_alive():
                if self._send_lock.acquire(False):
                    self.close()
                    self._send_lock.release()
            raise exc
