use better task ids

This commit is contained in:
j 2010-12-25 15:44:52 +05:30
parent 211cbc7d2b
commit af3625617d

View file

@ -17,11 +17,7 @@ from django.shortcuts import render_to_response, get_object_or_404, get_list_or_
from django.template import RequestContext from django.template import RequestContext
from django.conf import settings from django.conf import settings
try: from ox.utils import json
import simplejson as json
except ImportError:
from django.utils import simplejson as json
from ox.django.decorators import login_required_json from ox.django.decorators import login_required_json
from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response
from ox.django.http import HttpFileResponse from ox.django.http import HttpFileResponse
@ -84,7 +80,8 @@ def update(request):
if 'files' in data: if 'files' in data:
#update files info async, this takes to long otherwise #update files info async, this takes to long otherwise
#FIXME: how can client know if update is done? possibly with taksStatus? #FIXME: how can client know if update is done? possibly with taksStatus?
t = tasks.update_files.delay(user.username, data['volume'], data['files']) task_id = '_'.join(['update', user.username, data['volume']])
t = tasks.update_files.apply_async(args=[user.username, data['volume'], data['files']], task_id=task_id)
response['data']['taskId'] = t.task_id response['data']['taskId'] = t.task_id
user_profile = user.get_profile() user_profile = user.get_profile()
@ -192,7 +189,8 @@ def firefogg_upload(request):
f.save() f.save()
#FIXME: this fails badly if rabbitmq goes down #FIXME: this fails badly if rabbitmq goes down
try: try:
t = item.tasks.update_streams.delay(f.item.itemId) taks_id = 'update_streams_%s' % f.item.itemId
t = item.tasks.update_streams.apply_async(args=[f.item.itemId], task_id=task_id)
data['resultUrl'] = t.task_id data['resultUrl'] = t.task_id
except: except:
pass pass