Hello everyone Looking for suggestion on debugging...
# python
Hello everyone Looking for suggestion on debugging under VSCODE.
Copy code
import debugpy
debugpy.listen(("localhost", 5678))
print("Waiting for debugger attach...")
debugpy.wait_for_client()  # Only include this line if you want the script to pause until the debugger is attached.
print("Debugger attached."
set up the configuration and attached. Breakpoints are skipped and I see
pulumi:pulumi:Stack (app-dev):
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
asked ChatGPT for suggestion with Pulumi and it hallucinated the --exec option. which aparently does not exist..
Copy code
PYTHONPATH=$(python -c "import sys; print(':'.join(sys.path))") pulumi up --exec "python -Xfrozen_modules=off __main__.py"
Any pointers ?? thank you
I don't think there's currently a way to pass extra options to python. For nodejs there's the
option https://www.pulumi.com/docs/concepts/projects/project-file/#runtime-options Consider creating a feature request on https://github.com/pulumi/pulumi to get something similar added for python.
This is my VSCode configuration for running Pulumi in debug mode. The launch task sets the env variable
and the Python entrypoint uses that to determine whether to start a debugpy session. I include this conditional check in all my Pulumi entrypoints as it won't interrupt operations when I don't want debug mode. Native VScode (UI) breakpoints are working 99% of the time but in some rare cases I've had to explicitly insert a
line where I want the debugger to break.
Thanks Olafur. The issue was the main.py being in a subfolder with incorrect localRoot. Once corrected as below , it steps through like a champ
Copy code
"pathMappings": [
                    "localRoot": "${workspaceFolder}/awsx",
                    "remoteRoot": "."