Hello! I've searched through the docs, google, and...
# general
e
Hello! I've searched through the docs, google, and slack here trying to figure out how to have a fastapi service reload when files change during debugging. It will only reload when the debugger is not attached...is there a way around this?
As an alternative - watchdog watchmedo works, except i have to reattach the VS Code debugger....
Copy code
watchmedo auto-restart -d ./src/python -R -p '*.py' -- pants run --debug-adapter src/python/services/api/main.py
Any other thoughts?
tried combining that with
autoReload
in vs code
Copy code
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Attach to process",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "127.0.0.1",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ],
            "justMyCode": true,
            "redirectOutput": true,
            "autoReload": {
                "enable": true,
                "exclude": [
                    "**/.git/**",
                    "**/__pycache__/**",
                    "**/.pants.d/**",
                    "**/.vscode/**",
                    "**/dist/**",
                    "**/scripts/**",
                    "**/.mypy_cache/**",
                    "**/site-packages/**",
                    "**/src/docker/**",
                ],
                "include": [
                    "**/*.py",
                    "**/*.pyw"
                ]
            }
        }
    ]
}
and it tries to reload but vs code errors out with:
code reload: Unable to find module anyio._backends._asyncio to reload for path: /users/<path to src>/python/services/api/main.py
so looks like it's trying to handle too much instead of just re-attaching
probably because it's trying to allow code to be modified while at a break-point and then continue executing the modified code....I just want a simple re-attach without button clicking at minimum. The other would be great, but is likely more complex and beyond what's supported right now.