def write(self, message):
data = encode(message, compressed=self.compressed)<EOL>length = len(data)<EOL>data = self.__pack(length) + data<EOL>with self.__write_lock:<EOL><INDENT>while data:<EOL><INDENT>try:<EOL><INDENT>n = os.write(self.out_d, data)<EOL><DEDENT>except OSError as why:<EOL><INDENT>if why.errno in (errno.EPIPE, errno.EINVAL):<EOL><INDENT>raise EOFError()<EOL><DEDENT>raise<EOL><DEDENT>if not n:<EOL><INDENT>raise EOFError()<EOL><DEDENT>data = data[n:]<EOL><DEDENT><DEDENT>return length + self.packet<EOL>
Write outgoing message.