'Store return value and state of an executed task.'

def _store_result(self, task_id, result, state, traceback=None, request=None, **kwargs):

    meta = {u'_id': task_id, u'status': state, u'result': self.encode(result), u'date_done': datetime.utcnow(), u'traceback': self.encode(traceback), u'children': self.encode(self.current_task_children(request))}
    try:
        self.collection.save(meta)
    except InvalidDocument as exc:
        raise EncodeError(exc)
    return result
