Fastapi: __call__() missing 1 required positional argument: 'send' FastAPI on App Engine

Created on 15 Aug 2020  路  4Comments  路  Source: tiangolo/fastapi

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 last):
  File "/env/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle
    self.handle_request(listener, req, client, addr)
  File "/env/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
TypeError: __call__() missing 1 required positional argument: 'send'

Docker File:

FROM gcr.io/google_appengine/python

RUN apt-get update && apt-get install -y ffmpeg

# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.

RUN virtualenv /env -p python3.7

# Setting these environment variables are the same as running
# source /env/bin/activate.

ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

# Add the application source code.

ADD . /app

CMD gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app

app.yaml

runtime: custom
env: flex
entrypoint: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
service: encoder

runtime_config:
  python_version: 3

handlers:

- url: /.*
  script: auto
question

Most helpful comment

Show your code please, dockerfile and yaml have nothing with this error

All 4 comments

Show your code please, dockerfile and yaml have nothing with this error

I'm quoting this right from @di's answer from Stackoverflow

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.

Is the problem resolved @JoshBello? If it is, do you mind closing the issue? :smile:

Thanks for the help here everyone! :clap: :bow:

Thanks for coming back and closing the issue :+1:

Was this page helpful?
0 / 5 - 0 ratings