Authored by 💻

UWSGI spooler example leveraging django


    pks = qs.values_list('pk')
    Task(callback='yourmodule.yourcallback', env={'pks': pks}, total=len(pks))()


    def yourcallback(task):
        task.user  # auto-filled if you have django-threadlocals
        task.creation_ip # same
        task.env  # the picklefield, be carefull with SECURITY !! don't let users inject shit !! unpickling aint safe
        for pk in task.env['pks']:
            task.progress += 1

            # sub task
            sub_task = Task(parent=task, callback='update_stuff', env=dict(pk=pk))

            # not sure how we're going to do progress aggregation from subtask yet
            # oh well, we'll see about that when there's a sponsor
Edited 3.29 KB
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment