-
Notifications
You must be signed in to change notification settings - Fork 69
Not restart debugging #1942
Comments
There are no errors or really anything unusual in ptvsd logs here, but this gets logged by VSC in Output -> Log (Window):
which corresponds to: So, the problem is that IDE gives us 500 ms to terminate, and after that considers it an error. The problem is that it takes us longer to fully handle a graceful shutdown - in my repro, around 600 ms from the moment we receive "disconnect", to the moment we respond to it. The error itself occurs when using "Stop" as well, but in that case the only side effect is it being logged by VSC. However, if using "Restart", VSC will simply not proceed if it failed to stop the process. It also doesn't display any error message, so if you don't have the log window opened, there's no indication as to what went wrong. |
We can reduce the timeout for process exit to match what VSC expects, but this means that we will almost always be force-killing the debuggee process from the launcher if "Stop" or "Restart" is used, instead of letting pydevd terminate the process from inside in response to "disconnect" with "terminateDebuggee":true that we send to it. At the minimum, this means that child processes might not get cleaned up. @fabioz, is there anything else on the pydevd shutdown path that would result in some adverse effects if it doesn't get a chance to run to completion? |
@int19h the timeout is probably due to: https://github.com/microsoft/ptvsd/blob/master/src/ptvsd/_vendored/pydevd/pydevd.py#L1983 The shutdown procedure in This is done to ensure that all messages are received by the client before the shutdown. So, I think that the first thing is making sure that As a note, this was all done to ensure messages are sent -- i.e. in #1699, which was closed and reopened. I think that making that timeout lower may increase the likelihood that messages aren't received (especially on tests, if there are lots of tests running in parallel I think that it may be likely that under heavy load we may hit those limits, which may be the reason why we have this occurrences in the ci -- to be sure we could raise those limits to a big value... say, 20 seconds when running on the ci to see if we ever find the issue related to partial messages or not, so, maybe we could read the default timeout from an environment variable -- default would be 0.3 seconds and in the ci it'd be 20 seconds). What do you think? |
It's getting closed on the adapter side, but it's a bit convoluted. Here's the log showing the sequence, starting from when the adapter gets "disconnect" from the IDE:
So first of all it passes "disconnect" over to the server, but adds "terminateDebuggee", since "launch" implies that. Then it waits for "exited" event from the launcher (which just sits and waits on the process handle, and sends that event when that wait is done) - but in the meantime continues processing messages from the server. The server sends "terminated" event shortly after, indicating that message queue is flushed; the adapter closes the socket to the server in response. Note that the time stamps here all indicate rapid processing. The next thing is the launcher reporting that the debuggee has exited, and it's where the 500ms delay first appears. And it does appear to correspond to the 500ms timeout in pydevd code that you linked to, but it's not clear to me what else could be blocking it to trigger that timeout... |
Issue Type: Bug
Debug a Python script;
Stop at a breakpoint;
Then hit restart, but nothing happened.
Extension version: 2019.11.49689
VS Code version: Code 1.40.1 (8795a9889db74563ddd43eb0a897a2384129a619, 2019-11-13T16:47:44.719Z)
OS version: Darwin x64 18.7.0
Remote OS version: Linux x64 3.10.0-957.5.1.el7.x86_64
System Info
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: