microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.34k stars 28.9k forks source link

Can't run Flask app to gebug - terminals don't work properly #86544

Closed saasforge closed 4 years ago

saasforge commented 4 years ago

Issue Type: Bug

  1. Create Flask app
  2. Configure venv, install packages, set up launch.json, set up interpreter
  3. Add Flask Python configuration
  4. Add a new Integrated terminal
  5. Debug -> Start debugging
  6. The app is running (but it looks like the debugger is not enabled because it doesn't stop on breakpoints)
  7. Stop app
  8. Debug -> Start debugging

Expected: running app stopping on breakpoints

Instead: Vs code creates a new terminal, jumps there, nothing happens, then the exception message is shown: "Timeout waiting for debugger connection"

I use the following configuration:

    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "application.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "0"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true,
            "justMyCode": false
        }
    ]

Note. Sometimes it suddenly works but it immediately shows the following exception:

Exception has occurred: KeyError
(<class 'bytes'>, b'\\\\[0-3][0-7][0-7]', 0)
  File "C:\Development\Python35-64\Lib\re.py", line 281, in _compile
    p, loc = _cache[type(pattern), pattern, flags]
  File "C:\Development\Python35-64\Lib\re.py", line 224, in compile
    return _compile(pattern, flags)
  File "D:\Projects\Code\mainsite\venv\Lib\site-packages\werkzeug\_internal.py", line 43, in <module>
    _octal_re = re.compile(br'\\[0-3][0-7][0-7]')
  File "D:\Projects\Code\mainsite\venv\Lib\site-packages\werkzeug\exceptions.py", line 67, in <module>
    from werkzeug._internal import _get_environ
  File "D:\Projects\Code\mainsite\venv\Lib\site-packages\werkzeug\__init__.py", line 151, in <module>
    __import__('werkzeug.exceptions')
  File "D:\Projects\Code\mainsite\venv\Lib\site-packages\flask\__init__.py", line 17, in <module>
    from werkzeug.exceptions import abort
  File "C:\Development\Python35-64\Lib\runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "C:\Development\Python35-64\Lib\runpy.py", line 133, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\Development\Python35-64\Lib\runpy.py", line 174, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)

VS Code version: Code 1.40.2 (f359dd69833dd8800b54d458f6d37ab7c78df520, 2019-11-25T14:54:45.096Z) OS version: Windows_NT x64 6.1.7601

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz (8 x 2793)| |GPU Status|2d_canvas: enabled
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: unavailable_off
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: unavailable_off| |Load (avg)|undefined| |Memory (System)|15.96GB (1.10GB free)| |Process Argv|| |Screen Reader|no| |VM|57%|
Extensions (4) Extension|Author (truncated)|Version ---|---|--- python|ms-|2019.11.50794 vetur|oct|0.22.6 ejs-language-support|Qas|0.0.1 grammarly|znc|0.1.7
saasforge commented 4 years ago

Some additional information. I think the exception above was thrown because of the improper configuration of .env file (I fixed it now). After that, I was able to go into breakpoints. But the problem with terminal still persist: every time when I run debugging it creates a new terminal (called Python debug console), and jumps there, and it works if this terminal is open fresh - every second time the debugging doesn't work. The workaround is I have to close this new terminal every time when I stopped debugging.

vscodebot[bot] commented 4 years ago

This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines.

Happy Coding!

saasforge commented 4 years ago

This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines.

Happy Coding!

Which extension are you talking about? The debugging is broken. The debugger just can't get to the terminal right.

weinand commented 4 years ago

Python? VS Code does not support Python out of the box.

saasforge commented 4 years ago

Ok, let me ask Python extension community. Thanks!