__call __ ()에 1 개의 필수 위치 인수 누락 : App Engine의 FastAPI 'send'
Aug 15 2020
App Engine에서 API를 호스팅하려고 할 때 다음 오류가 계속 발생합니다. 이 프로그램은 작동했지만 매우 느린 Flask에서 실행되었습니다.
오류:
"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 파일 :
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
답변
1 DustinIngram Aug 18 2020 at 01:36
App Engine에서는 WSGI 애플리케이션에 해당 main.py
하는 app
변수 를 선언 하기 위해 파일이 필요합니다 .
FastAPI는 비동기 웹 프레임 워크이기 때문에 WSGI (동기)와 호환되지 않습니다.
가장 좋은 방법은 Cloud Run 과 같은 서비스를 사용하는 것입니다.이를 통해 자체 런타임을 정의하고 FastAPI와 호환되는 비동기 HTTP 서버를 사용할 수 있습니다.