Skip to content

Debugger doesn't stop after code execution ends. #2556

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

Closed
Balky79 opened this issue Sep 12, 2018 · 6 comments
Closed

Debugger doesn't stop after code execution ends. #2556

Balky79 opened this issue Sep 12, 2018 · 6 comments
Assignees
Labels
area-debugging bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@Balky79
Copy link

Balky79 commented Sep 12, 2018

Environment data

  • VS Code version: 1.27.1
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7, Anaconda, Python 2.6...
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv, conda, N/A
  • Relevant/affected Python packages and their versions: all above

Actual behavior

Running the python script fails to pick up depending local modules.
Debugging mode never finishes, and when stopped manually it causes an "error in debugger Banner" error.

Expected behavior

Everything to work as it worked with VS Code version 1.27.0

Steps to reproduce:

Create a blank .py script, and try to import script from the same folder.
Run your script.
Observe debugging banner / Trackback dump.

Logs

When used directly with a folder where python is installed:
Traceback (most recent call last): File "C:\Python35\lib\runpy.py", line 170, in _run_module_as_main "__main__", mod_spec) File "C:\Python35\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 211, in <module> singlesession=args.single_session) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 203, in main run_main(addr, name, kind, *extra, **kwargs) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 37, in run_main runner(addr, name, kind == 'module', *extra, **kwargs) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\runner.py", line 32, in run set_trace=False) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run return self._exec(is_module, entry_point_fn, module_name, file, globals, locals) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "c:\!IgorBackup\python-automation-scripts\PyScripts\blankStart.py", line 9, in <module> import sqlite3_hello_world ImportError: No module named 'sqlite3_hello_world'

When used with Anaconda virtualenv:
Traceback (most recent call last): File "g:\Anaconda3\Lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "g:\Anaconda3\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 211, in <module> singlesession=args.single_session) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 203, in main run_main(addr, name, kind, *extra, **kwargs) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 37, in run_main runner(addr, name, kind == 'module', *extra, **kwargs) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\runner.py", line 32, in run set_trace=False) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run return self._exec(is_module, entry_point_fn, module_name, file, globals, locals) File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "c:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "c:\!IgorBackup\python-automation-scripts\PyScripts\blankStart.py", line 9, in <module> import sqlite3_hello_world ModuleNotFoundError: No module named 'sqlite3_hello_world'

msft-01
msft-02
msft-03

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

console.ts:136 [Extension Host] Python Extension: Error in debugger Banner Error: Missing required @injectable annotation in: Random.
	at getTargets (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\planning\reflection_utils.js:20:15)
	at Object.getDependencies (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\planning\reflection_utils.js:11:19)
	at C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\planning\planner.js:106:51
	at Array.forEach (<anonymous>)
	at _createSubRequests (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\planning\planner.js:94:20)
	at Object.plan (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\planning\planner.js:129:9)
	at C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\container\container.js:316:37
	at Container._get (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\container\container.js:309:44)
	at Container.get (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\node_modules\inversify\lib\container\container.js:228:21)
	at ServiceContainer.get (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\ioc\container.js:28:89)
	at DebuggerBanner.<anonymous> (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:163:55)
	at Generator.next (<anonymous>)
	at C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:18:71
	at new Promise (<anonymous>)
	at __awaiter (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:14:12)
	at DebuggerBanner.getDebuggerLaunchThresholdCounter (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:158:16)
	at DebuggerBanner.<anonymous> (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:135:22)
	at Generator.next (<anonymous>)
	at C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:18:71
	at new Promise (<anonymous>)
	at __awaiter (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:14:12)
	at DebuggerBanner.passedThreshold (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:133:16)
	at DebuggerBanner.<anonymous> (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:72:30)
	at Generator.next (<anonymous>)
	at C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:18:71
	at new Promise (<anonymous>)
	at __awaiter (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:14:12)
	at DebuggerBanner.shouldShow (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:68:16)
	at DebuggerBanner.<anonymous> (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:188:37)
	at Generator.next (<anonymous>)
	at fulfilled (C:\Users\istojako\.vscode\extensions\ms-python.python-2018.8.0\out\client\debugger\banner.js:15:58)
	at <anonymous>
@d3r3kk d3r3kk added bug Issue identified by VS Code Team member as probable bug needs verification area-debugging labels Sep 12, 2018
@d3r3kk d3r3kk self-assigned this Sep 12, 2018
@d3r3kk
Copy link

d3r3kk commented Sep 12, 2018

@Balky79, thanks for the report!

There may be two problems going on here, let's try and tackle them one by one.

  1. The extension is raising an error regarding the use of a DebuggerBanner.

This is a bug with our latest version of the extension, and one that we will have to fix as soon as we can. Our team will triage this today and determine if we can put out a fix for it right now or provide a workaround for you.

  1. The debugger doesn't work for a file imported from the same folder.

I cannot reproduce this, as the simple reproduction case you provide is something that works without fail for me. Could you provide us with a minimum sample of code that has a reproduction on your machine?

It is possible that the two issues are related so I will attempt to reproduce #2 on my machine a bit further by forcing #1 to happen alongside it.

@d3r3kk d3r3kk changed the title Debugger never ends when running the script, and it fails to pick local dependencies Debugger Banner fails to open, potentially causing issues during debugging. Sep 12, 2018
@d3r3kk d3r3kk changed the title Debugger Banner fails to open, potentially causing issues during debugging. Debugger doesn't pick up depending local modules. Sep 12, 2018
@Balky79
Copy link
Author

Balky79 commented Sep 12, 2018

@d3r3kk thanks for looking into it.

You are most likely correct, as I created a blank new project in a separate folder, and there it seems that Debugging Banner goes away when the script execution is performed, however it still causes a nasty .js error that I pasted above.

However, just by adding the following configuration code into my launch.json I'm getting the same problem again.

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

In this "blank" project, I can't (just yet) reproduce the second issue, but since you changed the title to it, it seems you managed to get it.

@d3r3kk
Copy link

d3r3kk commented Sep 12, 2018

Apologies: I should not have changed the title as I had before. This issue will deal only with the 2nd issue I wrote up above - the problem with debugging a file that imports from a file in the same folder.

The debugger banner issue is unrelated and can be ignored, I've already discovered the problem with the banner and submitted a fix. The banner doesn't come up until after a debugging session ends.

Thanks for providing your launch.json block, that actually helped a lot.

I can reproduce your issue where the debugger does not complete now.

The "debugOptions" section doesn't seem to be supported, perhaps that is a leftover from the prior debugger? If you remove the section altogether I believe you may find it will begin to work properly.

@d3r3kk d3r3kk added info-needed Issue requires more information from poster and removed needs verification labels Sep 12, 2018
@d3r3kk d3r3kk changed the title Debugger doesn't pick up depending local modules. Debugger doesn't stop after code execution ends. Sep 12, 2018
@Balky79
Copy link
Author

Balky79 commented Sep 13, 2018

@d3r3kk

You are correct, taking the "debugOptions" out does remove the debugging banner. However. I'm still not able to pinpoint what is causing the issue with the local modules not being loaded.

And, an update on the local modules not being loaded issue:
It happens only when "run without debugging" mode is used, but if I use it in debugging, it works.

I can't figure out if there's a separate configuration for "run without debugging" where something might be not set properly.

And additional update, it happens only if there's "main" used. snippet of code:

import callable

def main():
    print(callable.MY_NAME)

if __name__ == '__main__':
    main()

Which is actually visible from the error message:

File "c:\Python35\Lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)

Thanks for the help on these issues.

@d3r3kk
Copy link

d3r3kk commented Sep 13, 2018

You are correct, taking the "debugOptions" out does remove the debugging banner.

Do you mean that it corrects the problem where the debugger fails to complete after code execution is completed? If so, then this issue is closed 😄 .

It happens only when "run without debugging" mode is used, but if I use it in debugging, it works.

Interesting. In the interest of keeping our issues concise, please open a different issue for this problem.

@Balky79
Copy link
Author

Balky79 commented Sep 14, 2018

You are correct, taking the "debugOptions" out does remove the debugging banner.

Do you mean that it corrects the problem where the debugger fails to complete after code execution is completed? If so, then this issue is closed 😄 .

Well, it seems so ;) So I'd say - yes, let's close this one.

It happens only when "run without debugging" mode is used, but if I use it in debugging, it works.

Interesting. In the interest of keeping our issues concise, please open a different issue for this problem.

I'll open the new issue now for this.

@Balky79 Balky79 closed this as completed Sep 14, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 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 info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants