Skip to content

Instantly share code, notes, and snippets.

@skyl
Created January 12, 2011 04:39
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyl/775697 to your computer and use it in GitHub Desktop.
Save skyl/775697 to your computer and use it in GitHub Desktop.
@transaction.commit_on_success
def _action(action, o):
getattr(o,action)()
o.is_processing = False
o.save()
def _bulk_action(action, objs):
for o in objs:
_action(action,o)
def bulk_action(request, t):
...
objs = model.objects.filter(pk__in=pks)
if request.method == 'POST':
objs.update(is_processing=True)
from multiprocessing import Process
p = Process(target=_bulk_action,args=(action,objs))
p.start()
return HttpResponseRedirect(next_url)
context = {'t': t, 'action': action, 'objs': objs, 'model': model}
return render_to_response(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment