def list_tasks(request_args, status=None):
    """General listing tasks function.

    :param request_args: Arguments passed to request.
    :param status: Status filter (e.g. 'SUCCESS').
    """
    limit = 1000

    if 'limit' in request_args:
        try:
            limit = int(request_args['limit'])
        except ValueError:
            res = ErrorAPIResponse(3000).to_dict()
            return jsonify(res), 400

        if limit < 1:
            res = ErrorAPIResponse(3000).to_dict()
            return jsonify(res), 400

    # unitialized db - no tasks
    if not engine.dialect.has_table(engine, 'celery_taskmeta'):
        return jsonify([])

    try:
        session = Session()

        if status:
            tasks = session.query(Task).filter(Task.status == status).order_by(
                Task.date_done.desc()).limit(limit)
        else:
            tasks = session.query(Task).order_by(
                Task.date_done.desc()).limit(limit)

    except (exc.SQLAlchemyError, exc.OperationalError):
        session.rollback()
    finally:
        session.close()

    res = []
    for task in tasks:
        res.append(task.to_dict())

    return jsonify(res)
General listing tasks function.

    :param request_args: Arguments passed to request.
    :param status: Status filter (e.g. 'SUCCESS').
    
lisa/web_api/routes.py