Skip to content
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

Debug error when finished running code in integrated/external terminal #191

Closed
DonJayamanne opened this issue Nov 14, 2017 · 7 comments · Fixed by #249 · May be fixed by whitedragon206/vscode-python#3
Closed

Debug error when finished running code in integrated/external terminal #191

DonJayamanne opened this issue Nov 14, 2017 · 7 comments · Fixed by #249 · May be fixed by whitedragon206/vscode-python#3
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@DonJayamanne
Copy link

From @JasonGoemaat on September 27, 2017 23:45

Environment data

VS Code version: 1.17.0-insider
Python Extension version: 0.7.0
Python Version: 3.6.2
OS and version: Windows 10

Actual behavior

Program debugs in terminal (either integrated or external) and a prompt not in the source appears when the program is finished:

Press any key to continue . . .

After pressing a key, either A) External terminal closes or B) Integrated terminal returns to the command prompt. At the same time an error pops up at the top of the visual studio code window that I have to close:

[Error] Debug adapter process has terminated unexpectedly

Expected behavior

After program has finished and I press a key, no error message is displayed

Steps to reproduce:

  • Create sample python file, i.e. "print('Hello, world')"
  • Debug the file using either the external or integrated terminals

Logs

Output from Python output panel

Output from Console window (Help->Developer Tools menu)

Debug adapter process has terminated unexpectedly          messageService.ts:125
    e.doShow                               @messageService.ts:125
    e.show                                 @rawDebugSession.ts:104
    _.onServerExit                         @rawDebugSession.ts:526
    (anonymous)                            @rawDebugSession.ts:440
    emitTwo                                @events.js:111
    emit                                   @events.js:194
    __dirname.ChildProcess._handle.onexit  @internal/child_process.js:215

Copied from original issue: DonJayamanne/pythonVSCode#1250

@DonJayamanne
Copy link
Author

DonJayamanne commented Nov 14, 2017

prompt not in the source appears when the program is finished:

What do you mean by the above statement?

Does the debug window display the text Hello, world

@DonJayamanne
Copy link
Author

From @General-Gouda on October 19, 2017 15:53

I am also getting the same error after every debug session. See attached GIF for demonstration.

VS Code version: 1.17.2
Python Extension version: 0.7.0
Python Version: 3.6.2
OS and version: Windows 10 Creators Update v10.0.15063

2017-10-19_11-48-04

launch.json debug config I ran:
{
"name": "Integrated Terminal/Console",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
},

@Pierre-Royer
Copy link

Hi,

Same problem here with most recent version.

VS Code version: 1.18.0
Python Extension version: 0.8.0
Python Version: 3.6.2
OS and version: Windows 10

        "name": "Python",
        "type": "python",
        "request": "launch",
        "stopOnEntry": false,
        "console": "externalTerminal", //whatever the console output settings
        "pythonPath": "${config:python.pythonPath}",
        "program": "${file}",
        "cwd": "${workspaceRoot}",
        "env": {},
        "envFile": "${workspaceRoot}/.env",
        "debugOptions": [
            "WaitOnAbnormalExit",
            "WaitOnNormalExit",
            "RedirectOutput"
        ]

image

Thanks for your help.

@DonJayamanne
Copy link
Author

@Pierre-Royer Are you debugging the code or just running it without debugging (using CTRL+F5)?

@Pierre-Royer
Copy link

With CTRL-F5 I have no problem at all. This issue occurs only while debugging the code (F5) and exit the app or close the console. It doesn't occurs when I stop the debugging (SHIFT-F5).

@brettcannon brettcannon added awaiting 1-verification area-debugging bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2017
@JasonGoemaat
Copy link

By "prompt not in the source appears when the program is finished:" I mean that after my program completes and I see for example "Hello, world!" in the debug window, another prompt appears saying Press any key to continue . . .. I assume this is from the python extension when debugging since it isn't in my code and it doesn't appear when I run my program with python myself.. After I press a key the integrated terminal returns to the prompt and the error is displayed in vscode.

Here is the terminal:

PS C:\git\python> cd 'c:\git\python'; $env:PYTHONIOENCODING='UTF-8'; $env:PYTHONUNBUFFERED='1'; c:/python36/python C:\Users\Jason\.vscode-insiders\extensions\ms-python.python-0.8.0\pythonFiles\PythonTools\visualstudio_py_launcher.py c:\git\python 50640 34806ad9-833a-4524-8cd6-18ca4aa74f14 WaitOnAbnormalExit,WaitOnNormalExit c:\git\python\HelloWorld.py
Hello, world!
Press any key to continue . . .

If I edit the configuration to remove WaitOnNormalExit I don't get the prompt, but still get the error message when the program finishes. No error appears in the terminal in either case, just the pop-up in visual studio that it terminated unexpectedly.

@DonJayamanne DonJayamanne added this to the December 2017 milestone Nov 17, 2017
DonJayamanne added a commit that referenced this issue Nov 22, 2017
#249)

- Fixes #25, #32, #35, #235, #242 (unable to run without debugging using CTRL+F5)   
- Fixes #191, #158, #24, #136  (error message displayed when debugged code terminates)  
- Fixes #157 (debugger crashes when python program does not launch)
- Fixes #114, #149, #250 (use vscode infrastructure to launch debugger in integrated and external terminals)  
- Fixes #239 Remove prompt added to pause terminal upon program completion
@brettcannon
Copy link
Member

Considering as a dupe of #239

@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug
Projects
None yet
4 participants