question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] FastAPI on Google AppEngine

See original GitHub issue

Description

Is it possible to use FastAPI on Google AppEngine?

Additional context

I have tried a minimal project, with:

  • the main.py example on the repo README.md,
  • requirements.txt containing just fastapi and uvicorn
  • app.yaml containing just runtime: python37

When deploying, I get the following error:

Traceback (most recent call last):
  File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 279, in handle
    keepalive = self.handle_request(req, conn)
  File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 328, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
TypeError: __call__() takes 2 positional arguments but 3 were given

I have tried different variations, but I always end up with this error.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
euri10commented, Sep 4, 2019

just quoting uvicorn doc 👍

Running with Gunicorn Gunicorn is a mature, fully featured server and process manager.

Uvicorn includes a Gunicorn worker class allowing you to run ASGI applications, with all of Uvicorn’s performance benefits, while also giving you Gunicorn’s fully-featured process management.

This allows you to increase or decrease the number of worker processes on the fly, restart worker processes gracefully, or perform server upgrades without downtime.

For production deployments we recommend using gunicorn with the uvicorn worker class.

gunicorn example:app -w 4 -k uvicorn.workers.UvicornWorker For a PyPy compatible configuration use uvicorn.workers.UvicornH11Worker.

For more information, see the deployment documentation.

5reactions
hiovidiucommented, May 15, 2019

Thank you @euri10 ! You are right, the entrypoint is to blame.

For future reference, the following app.yaml results in the error above:

runtime: python37
entrypoint: gunicorn main:app

while the correct version is:

runtime: python37
entrypoint: gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker
Read more comments on GitHub >

github_iconTop Results From Across the Web

FastApi + Gunicorn workers + Google app engine
Please be sure to answer the question. Provide details and share your research! ... Asking for help, clarification, or responding to other answers ......
Read more >
Deploying FastAPI application in Google App Engine in ...
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
Read more >
Deploy FastAPI Python app to Google Cloud Platform on ...
In this tutorial we will deploy a Simple FastAPI application written in Python to GCP (Google Cloud Platform) Google App Engine.
Read more >
Building a Python 3 App on App Engine - Google Cloud
Use this guide to learn the basics of developing and deploying Python 3 web services to the App Engine standard environment. In this...
Read more >
tiangolo/fastapi - Gitter
question is if you have 50 cookies. :laughing: Sebastián Ramírez ... Anybody using it in production right now w/ Google Cloud SQL? ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found