@app.route('/api/work_queue/<string:queue_name>/lease', methods=['POST'])
@auth.superuser_api_key_required
@utils.retryable_transaction()
def handle_lease(queue_name):
    owner = request.form.get('owner', request.remote_addr, type=str)
    try:
        task_list = work_queue.lease(
            queue_name,
            owner,
            request.form.get('count', 1, type=int),
            request.form.get('timeout', 60, type=int))
    except work_queue.Error, e:
        return utils.jsonify_error(e)

    if not task_list:
        return flask.jsonify(tasks=[])

    db.session.commit()
    task_ids = [t['task_id'] for t in task_list]
    logging.debug('Task leased: queue=%r, task_ids=%r, owner=%r',
                  queue_name, task_ids, owner)
    return flask.jsonify(tasks=task_list)
Leases a task from a queue.
dataset/ETHPy150Open bslatkin/dpxdt/dpxdt/server/work_queue_handlers.py/handle_lease