Skip to content Skip to sidebar Skip to footer

__call__() Missing 1 Required Positional Argument: 'send' Fastapi On App Engine

When trying to host an API on App Engine, the following error keeps coming up. The program used to run on Flask which was working but very slow. Error: 'Traceback (most recent call

Solution 1:

As Dustin said I found out that worker class need to be changed. Try the below one.

gunicorn -k uvicorn.workers.UvicornWorkermain:app

Found this on github issues

Solution 2:

App Engine requires your main.py file to declare an app variable which corresponds to a WSGI Application.

Since FastAPI is an asynchronous web framework, it is not compatible with WSGI (which is synchronous).

Your best option would be to use a service like Cloud Run, which would allow you to define your own runtime and use an asynchronous HTTP server compatible with FastAPI.

Solution 3:

I ran into the same issue when I want to deploy a FastAPI app to Heroku. Indeed, you can't use uvicorn (which is the ASGI framework that FastAPI is using) with Heroku that uses gunicorn.

However, by adding a uvicorn worker to gunicorn then it works!:

gunicorn api:app --bind 0.0.0.0:$PORT --worker-class uvicorn.workers.UvicornWorker

Post a Comment for "__call__() Missing 1 Required Positional Argument: 'send' Fastapi On App Engine"