def METHOD_NAME(sock, flags, *args):
    if flags & (GLib.IOCondition.HUP | GLib.IOCondition.ERR):
        self.close()
        return False
    if flags & GLib.IOCondition.OUT:
        if self.can_write():
            write_buffer.extend(self.handle_write())
        if not write_buffer:
            self._out_id = None
            return False
        while True:
            try:
                result = sock.send(write_buffer)
            except (IOError, OSError) as e:
                if e.errno in (errno.EWOULDBLOCK, errno.EAGAIN):
                    return True
                elif e.errno == errno.EINTR:
                    continue
                else:
                    self.close()
                    return False
            break
        del write_buffer[:result]
    return True