Exemple #1
0
def chain_clean_docs(doc_pks, user_pk):
    tasks = []
    count = 0
    total = len(doc_pks)
    n = int(ceil(total / 5))
    chunks = chunked(doc_pks, n)

    for chunk in chunks:
        count += len(chunk)
        tasks.append(clean_document_chunk.si(chunk, user_pk))
        percent_complete = int(ceil((count / total) * 100))
        tasks.append(
            email_document_progress.si("clean_document", percent_complete,
                                       total))

    chain(*tasks).apply_async()
Exemple #2
0
    def chain_render_docs(self, docs, cache_control, base_url, force):
        tasks = []
        count = 0
        total = len(docs)
        n = int(ceil(total / 5))
        chunks = chunked(docs, n)

        for chunk in chunks:
            count += len(chunk)
            tasks.append(
                render_document_chunk.si(chunk, cache_control, base_url,
                                         force))
            percent_complete = int(ceil((count / total) * 100))
            tasks.append(
                email_document_progress.si('render_document', percent_complete,
                                           total))

        # Make it so.
        chain(*tasks).apply_async()