-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try soft-kill before hard-kill when terminating debugger #1022
Comments
@tjnd89 I don't really have excel here to test, but we should be killing the whole process tree (so, if excel is not part of the process tree this could explain it). Can you do one test: if you use taskkill directly by running the command line below (replacing the
Does it work? Note: you can get the pid by adding the code below in your script.
|
@fabioz I tried your test. The Excel is not part of the script's process tree since it was originally started before even running the script. In the non-debugger case, the |
I meant for you to use Please try it with and without the |
Gotcha. I just tried again.
|
One more try: what happens if instead of doing the kill you go to the terminal and make a I guess one difference in our implementation is that we just force kill and I believe in Intellij they try a soft-kill first through a Ctrl+C. |
Ctrl-C in the terminal successfully stopped the debugger, then quitting Excel via it's UI showed that the Excel process went away. So it looks like the soft-kill did the right thing. |
It seems that to properly do this we should support: i.e.: The spec says:
|
@int19h @karthiknadig I've created #1023 as a draft as a possible approach to address this... |
Type: Bug
I've observed a strange behavior where VSCode does not release COM object references while debugging. PyCharm works fine. To see this in action do the following:
Start Excel (the problem occurs with other apps too, I'm using Excel for this example only because most people have it).
From the command line, run the script "excel_test.py" below. It attaches to the running Excel application and tries to call a non-existent method hi(). An exception is thrown and the script will exit, as expected.
Quit Excel manually by closing it via the UI. Note in the task manager that the Excel.exe process has shut down. This is all as expected.
Repeat the same steps but run the script using VSCode debug mode. When the exception is thrown the debugger halts execution. Press the Stop button on the debugger tool bar to terminate the script. After quitting Excel, notice that the UI has shutdown, but the Excel.exe process is still running. You now have a zombie process.
Following this same pattern in PyCharm debug mode works fine, the process goes away as expected.
Somehow it appears that VSCode is not properly releasing the COM object reference when exiting debug mode. Am I missing some weird setting or something, or is it just broken?
I'm running Python 3.9.12, pywin32 302, VSCode 1.70.2.
I've also opened up a StackOverflow question on this at https://stackoverflow.com/questions/73401543/vscode-debugger-not-releasing-com-object-reference-when-a-python-script-throws-a.
Extension version: 2022.12.1
VS Code version: Code 1.70.2 (e4503b30fc78200f846c62cf8091b76ff5547662, 2022-08-16T05:35:13.448Z)
OS version: Windows_NT x64 10.0.22000
Modes:
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: