GoogleContainerTools / GoogleContainerTools/skaffold
Skaffold debug breakpoints not hitting in Python with uvicorn --reload
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
I am developing in FastAPI + uvicorn. When using skaffold dev with file sync mode, I enable the uvicorn hot reloader. This works as intended. When switching to skaffold debug, I have to disable the uvicorn reloader in order for breakpoints to hit.
In order to work around this, I have to modify my Dockerfile whenever I want to use skaffold debug. I think I can also move the uvicorn options to main.py and only set reload=True when not running under a debugger.
FWIW, when PyCharm invokes pydevd directly, it sets the `--multiprocess` argument and uvicorn's reload works. Here is PyCharm's Python Debug:
```
C:\Users\minic\AppData\Local\Programs\Python\Python310\python.exe C:/Users/minic/AppData/Local/JetBrains/Toolbox/apps/PyCharm-P/ch-0/223.7571.203/plugins/python/helpers/pydev/pydevd.py --module --multiprocess --client 127.0.0.1 --port 51724 --file uvicorn app:app --reload --port 5001 --host 0.0.0.0 --use-colors
```
### Expected behavior
Breakpoints should hit in PyCharm as documented.
### Actual behavior
Breakpoint never hits. Manually pausing the debugger breaks in the watchfiles module, main.py.
### Information
- Skaffold version: v2.0.3
- Operating system: Windows 11
- Installed via: skaffold.dev
- Contents of skaffold.yaml:
```yaml
---
apiVersion: skaffold/v4beta1
kind: Config
metadata:
name: apps
build:
local:
# tryImportMissing: true
concurrency: 0
artifacts:
- image: fastapi-debug-test
sync:
infer:
- main.py
platforms:
- linux/amd64
manifests:
rawYaml:
- ./deployment.yaml
deploy:
kubectl: {}
portForward:
- resourceName: fastapi-deployment
resourceType: deployment
port: 8080
```
### Steps to reproduce the behavior
See README in https://github.com/usrbinsam/skaffold-debug-issue
Contributor guide
Assessment
This issue has not been assessed yet.