public
Last active

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
@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(...)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.