8000 gunicorn/fastapi not staring the application properly when using the reload=True flag · Issue #838 · emacs-lsp/dap-mode · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
gunicorn/fastapi not staring the application properly when using the reload=True flag #838
Open
@ltrojan

Description

@ltrojan

Hi everyone and thanks for the amazing package!

I'm struggling with running a fastapi application using the dap debugger

I'm running a uvicorn application using a python script:

# main.py

import uvicorn

if __name__ == "__main__":
    uvicorn.run(
        "myapp:app",
        host="0.0.0.0",
        port=8002,
        reload=True,
        log_level="debug"
    )

but when i run the dap-debug, the app never reaches the "Application startup complete."

here's the dap log of the template "Python :: Run file (buffer)":

please use uvicorn directly for production deployments instead
INFO:     Will watch for changes in these directories: ['/home/ltrojan/wilder/repo/myapp']
INFO:     Uvicorn running on http://0.0.0.0:8002 (Press CTRL+C to quit)
INFO:     Started reloader process [289169] using StatReload

and browsing to localhost:8002 would lead to a ERR_CONNECTION_REFUSED

this doesn't happen when not setting the reload=True. When that flag is removed, the logs would look like this:

INFO:     Started server process [291395]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8002 (Press CTRL+C to quit)

Also, please note that this doesn't seem to be de to debugpy as when i run the command from the command line, I can ping the localhost:8002 and receive a response:

poetry run debugpy --listen 5001 ./main.py

For some more context: I'm following the instructions on DAP plus Poetry plus venv; this is my emacs configuration:

(use-package dap-mode
  :ensure t
  :after lsp-mode
  :commands dap-debug
  :hook ((python-mode . dap-ui-mode)
         (python-mode . dap-mode))
  :config
  (require 'dap-python)
  (require 'with-venv)
  (setq dap-python-debugger 'debugpy)
  'dap-mode (defun dap-python--pyenv-executable-find (command)
              (let ((python-exec (with-venv (executable-find "python"))))
                (message "Found Python executable in pyenv-executable-find: %s" python-exec)
                python-exec))
  (add-hook 'dap-stopped-hook
            (lambda (arg) (call-interactively #'dap-hydra))))

any idea why this is happening?

thank you for the support!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0