profile
viewpoint

Ask questionswhen I debug, I meet: Runtime Error: Already started in multiprocess

Environment data

  • PTVSD version: 4.3.2
  • OS and version: Ubuntu 18
  • Python version: 3.6.8 (I am using virtual env )
  • Using VS code 1.38

same as #1443

i already add these 2 lines in my code:

import multiprocessing
multiprocessing.set_start_method('spawn', True)
error message:

E00007.569: Exception escaped from start_client
            
            Traceback (most recent call last):
              File "/home/mingming/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/log.py", line 110, in g
                return f(*args, **kwargs)
              File "/home/mingming/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/pydevd_hooks.py", line 74, in start_client
                sock, start_session = daemon.start_client((host, port))
              File "/home/mingming/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/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/mingming/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/mingming/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started
            

Traceback (most recent call last):

my launch.json:

 {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "enter-your-module-name-here",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "console": "integratedTerminal",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "django": true
        },
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        },
        {
            "name": "Python: Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        }
    ]
}

settings.json

{
    "python.pythonPath": "venv/bin/python"
}

do i need to modify launch.json? When I debug, I can see my python venv in effect.

microsoft/ptvsd

Answer questions naefl

Same issue here - prior to the October update, this issue would only occur in cell debugging for interactive python sessions. Now this happens with normal debugging as well.

I'm using sklearn

              File "/root/.vscode-server-insiders/extensions/ms-python.python-2019.10.41019/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/root/.vscode-server-insiders/extensions/ms-python.python-2019.10.41019/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
raise RuntimeError('already started')
            RuntimeError: already started
            

[Parallel(n_jobs=-1)]: Using backend LokyBackend with 16 concurrent workers.
Traceback (most recent call last):

Here's my launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "subProcess": true
        },
    ]
}
useful!
source:https://uonfu.com/
answerer
Luca Naef naefl VantAI New York City https://www.linkedin.com/in/lnaef/ Head of Analytics at VantAI. *We're hiring!* Machine learning driven Drug Discovery
Github User Rank List