-
Can we use poethepoet to launch a python program in debug mode? I am trying to use it with VSCode debugger with following launch config. {
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "poethepoet",
"args": ["start"],
"justMyCode": true,
"jinja": true
} My task definition [tool.poe.tasks]
start = { cmd = "python -m apps", help = "Start dev server (press F5 on VSCode)" } It seems like poethepoet is running in debug mode, but the flask server isn't. I can debug my flask app without poethepoet using flask launch config provided by VSCode, but the can't debug it with poethepoet and take advantage of |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
That's an interesting question. I'm not really familiar with how the vscode debug mode works exactly, though I imagine that at least part of the problem is that the poethepoet process that you're attaching to is different than the python subprocess created to execute the apps module in this case. In general poe runs tasks in subprocesses for a variety of reasons. The one exception to this rule is if you set I'm not sure if that'll help since although the task will run as the same process it's still a different python runtime. If that doesn't work then maybe there's some way to define the task to run the child process as the debug target, though I wouldn't know exactly how. Let me know if you work it out! |
Beta Was this translation helpful? Give feedback.
-
I was mistaken, it is not dependent on python version, rather depends on poethepoet version. The debugging only works in Finally figured it out, if poethepoet executes the command the debugger works, if it executes the command with The solution I came up with is very simple, just add the environment variable to vscode launch config ( {
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "poethepoet",
"args": ["start"],
"justMyCode": true,
"jinja": true,
"env": {
"POETRY_ACTIVE": "1"
}
} |
Beta Was this translation helpful? Give feedback.
Today I tested the same thing on Python 3.10 where it works just fine, but it doesn't work in 3.9. Is this a python related issue?I was mistaken, it is not dependent on python version, rather depends on poethepoet version. The debugging only works in
v0.16.1
, doesn't work on the earlier or later version (v0.16.2
). I wonder why it only works only on that version. Any idea?Finally figured it out, if poethepoet executes the command the debugger works, if it executes the command with
poetry run
prefix the debugger doesn't work (don't know why). VSCode debugger activates poetry virtual environment by running the virtualenv activate script, soPOETRY_ACTIVE
environment variable is not set, so…