Coder Social home page Coder Social logo

Comments (6)

tiangolo avatar tiangolo commented on September 24, 2024 3

@Kludex implemented integrated support in the official Python VS Code extension: microsoft/vscode-python#14606

Meanwhile, you can try these snippets: microsoft/vscode-python#14247 (comment)

from uvicorn-gunicorn-fastapi-docker.

geekkun avatar geekkun commented on September 24, 2024 1

My workaround is to add
import uvicorn
and at the bottom of the main.py

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)

And run it as a normal python file without docker at all. In pro version of pycharm it is possible to setup docker as a remote debugger, but I don't use that feature.

from uvicorn-gunicorn-fastapi-docker.

talnagar avatar talnagar commented on September 24, 2024

thank you. I'll check out pycharm

from uvicorn-gunicorn-fastapi-docker.

Sihomiri avatar Sihomiri commented on September 24, 2024

I do all of the above but then I get the following error when hitting the endpoint.

INFO: 127.0.0.1:50311 - "GET /coordinate/2 HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 385, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in call
return await self.app(scope, receive, send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/fastapi/applications.py", line 139, in call
await super().call(scope, receive, send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/applications.py", line 134, in call
await self.error_middleware(scope, receive, send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/middleware/errors.py", line 178, in call
raise exc from None
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/middleware/errors.py", line 156, in call
await self.app(scope, receive, _send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/exceptions.py", line 73, in call
raise exc from None
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/exceptions.py", line 62, in call
await self.app(scope, receive, sender)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/routing.py", line 590, in call
await route(scope, receive, send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/routing.py", line 208, in call
await self.app(scope, receive, send)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/starlette/routing.py", line 41, in app
response = await func(request)
File "/Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/fastapi/routing.py", line 111, in app
raw_response = await dependant.call(**values)
File "/Users/sihomiri/Documents/GPS/app.py", line 26, in get_coordinate
data = await dal.find("coordinates",{"id":id})
File "/Users/sihomiri/Documents/GPS/data_acces_layer.py", line 69, in find
for result in await cursor.to_list(length=100):
RuntimeError: Task <Task pending coro=<RequestResponseCycle.run_asgi() running at /Users/sihomiri/anaconda2/envs/py37/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py:385> cb=[set.discard()]> got Future attached to a different loop

from uvicorn-gunicorn-fastapi-docker.

NixBiks avatar NixBiks commented on September 24, 2024

@geekkun that does not support auto-reload though, right?

At least I had to do something like this in a file in my root folder for reload to work as well

if __name__ == "__main__":
    uvicorn.run("app.main:app", host="0.0.0.0", port=8000, reload=True)

from uvicorn-gunicorn-fastapi-docker.

github-actions avatar github-actions commented on September 24, 2024

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

from uvicorn-gunicorn-fastapi-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.