'Blocks until all pending highlighting requests are handled'

def join(self):

    doc = self.doc
    if (doc is None):
        self.requests.clear()
        return
    self.ignore_requests = True
    try:
        while self.requests:
            (start_cursor, end_cursor) = self.requests.popleft()
            block = start_cursor.block()
            last_block = end_cursor.block()
            if (not last_block.isValid()):
                last_block = doc.lastBlock()
            end_pos = (last_block.position() + last_block.length())
            force_next_highlight = False
            while (block.isValid() and (force_next_highlight or (block.position() < end_pos))):
                (formats, force_next_highlight) = self.parse_single_block(block)
                self.apply_format_changes(block, formats)
                doc.markContentsDirty(block.position(), block.length())
                block = block.next()
    finally:
        self.ignore_requests = False
