question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"RuntimeError: already started" after VSCode Update.

See original GitHub issue

Environment data

  • VS Code version: 1.46.1
  • Extension version: v2020.6.89148
  • OS and version: Mint 19.3 Cinamon
  • Python version: Python3.6
  • Type of virtual environment used: virtualenv + virtualenvwrapper
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): XXX
  • Value of the python.languageServer setting: XXX

I have been using VSCode to debug Python for almost a year now with the following run configuration from my launch.json file:

{
    "name": "Microservices",
    "type": "python",
    "request": "launch",
    "program": "/home/user/.virtualenvs/core-microservices/bin/gunicorn",
    "gevent": true,
    "args": [
        "main:app",
        "--bind=127.0.0.1:8080",
        "--worker-class",
        "eventlet",
        "-w",
        "4",
        "--timeout=7200"
    ],
    "envFile": "${workspaceFolder}/microservices.env",
    "postDebugTask": "killdebugger"
}

After the last update, when I try to run the debugger I get the following stack trace:

[2020-06-19 18:24:23 -0300] [18447] [INFO] Unhandled exception in main loop
Traceback (most recent call last):
  File "/home/mauricio/.virtualenvs/core-microservices/lib/python3.6/site-packages/gunicorn/arbiter.py", line 203, in run
    self.manage_workers()
  File "/home/mauricio/.virtualenvs/core-microservices/lib/python3.6/site-packages/gunicorn/arbiter.py", line 545, in manage_workers
    self.spawn_workers()
  File "/home/mauricio/.virtualenvs/core-microservices/lib/python3.6/site-packages/gunicorn/arbiter.py", line 616, in spawn_workers
    self.spawn_worker()
  File "/home/mauricio/.virtualenvs/core-microservices/lib/python3.6/site-packages/gunicorn/arbiter.py", line 567, in spawn_worker
    pid = os.fork()
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 528, in new_fork
    _on_forked_process()
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 50, in _on_forked_process
    pydevd.settrace_forked()
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2427, in settrace_forked
    patch_multiprocessing=True,
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2179, in settrace
    wait_for_ready_to_run,
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2230, in _locked_settrace
    debugger.connect(host, port)  # Note: connect can raise error.
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 1060, in connect
    s = start_client(host, port)
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 136, in _start_client
    return start_client(daemon, h, p)
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/log.py", line 110, in g
    return f(*args, **kwargs)
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 74, in start_client
    sock, start_session = daemon.start_client((host, port))
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 214, in start_client
    with self.started():
  File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
    self.start()
  File "/home/mauricio/.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
    raise RuntimeError('already started')

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Just try to debug a python application with the latest version of the VScode editor and the Python Extension as well.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX


Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

XXXX

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16

github_iconTop GitHub Comments

2reactions
int19hcommented, Jun 22, 2020

This commit removes the experiment along with the old debugger, so it actually fixes this issue, in a sense. But it was only merged 3 days ago, so it’s only present in insiders build, not in stable.

(Consequently, if you want a quick workaround - just install insiders!)

1reaction
int19hcommented, Jul 2, 2020

Looks like everybody received the fix, so I’m going to go ahead and close this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"RuntimeError: already started" after VSCode Update. #100609
This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in...
Read more >
Debugging runtime error, code correction.
There's just 1 little odd behaviour when debugging when a runtime error occurs, the code is running on another thread, and it breaks...
Read more >
how to fix this already started runtime error in GridSearchCV ...
Personally, I found that this issue only happens when I run the code through VSCode in debug mode. If I just run it...
Read more >
Can't open napari with Jupyter and VS Code - Usage & Issues
Can't open napari with Jupyter and VS Code - module 'napari' has no attribute 'Viewer' - RuntimeError: No Qt app has been created....
Read more >
VS Code Debugger not working for python - Microsoft Q&A
The Python extension is broken - just seems to have updated at the same time as VS Code. Go back to extension version...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found