<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _non_connect_send_msg(self, msg_code, data):
 """ Similar to self._send, but doesn't try to initiate a connection, thus preventing an infinite loop. """

        try:
            self._socket.sendall(self._encode_msg(msg_code, data))
        except (IOError, socket.error) as e:
            if e.errno == errno.EPIPE:
                raise ConnectionClosed(e)
            else:
                raise