def process_task(obj): target = 'download' from atracker.util import create_event process = Process() status, result, messages = process.run(instance=obj, format=obj.fileformat) if target == 'download': if result: obj.filesize = os.path.getsize(result) obj.file = DjangoFile(open(result), u'archive') # update status obj.status = 1 obj.save() process.clear_cache() else: obj.status = 99 obj.status_msg = messages obj.save() process.clear_cache()