Skip to content

How do I use async/await with flask-restx? #600

Open
@airedwin

Description

@airedwin

Ask a question
I have a simple route like

@ns_async.route('/async')
class AsyncResource(Resource):
    async def post(self,):

        await somefunction()

        return jsonify({
            'status': 'success'
        }), 200

when this route is called, i get an error saying that AsyncResource.post wasn't awaited
"RuntimeWarning: coroutine 'AsyncResource.post' was never awaited"

Additional context
the same function works when using normal flask[async]

@flask_app.route('/async', method=["POST"])
async def asyncfunc():

    await somefunction()

    return jsonify({
        'status': 'success'
    }), 200

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions