示例#1
0
    def process(self, q_item):
        if q_item.method == 'post':
            json_resp = self.post(url=q_item.url,
                                  data=json.loads(q_item.payload))
        else:
            json_resp = self.get(url=q_item.url)

        if 'error' in session:
            q_item.status = "error"
            error = session.pop('error')
            q_item.response = json.dumps(error)
            if q_item.retry_count is None:
                q_item.retry_count = 0
            else:
                q_item.retry_count += 1
            Queue.update(q_item)
            return error
        else:
            if q_item.cache_name:
                Cache.set_data(q_item.cache_name,
                               json_resp,
                               is_unique=q_item.cache_is_unique)

            q_item.status = "ok"
            q_item.response = json.dumps(json_resp)

        Queue.update(q_item)
        return json_resp
示例#2
0
def process(action, hash_item):
    if action == 'delete':
        Queue.delete(hash_item)

        return 'deleted'
    elif action == 'play':
        q_item = Queue.get(hash_item)
        response = api_client.process(q_item)

        return jsonify(response)

    elif action == 'suspend':
        q_item = Queue.get(hash_item)
        q_item.status = 'suspend'
        Queue.update(q_item)

    return f"{q_item.hash_item} {action}ed"
示例#3
0
def update_queue():
    q = Queue.get("27f1daa58b456bb0702bae8575a9ec1e")
    q.status = "error"
    Queue.update(q)
    return show_queue("update")