microsoft/vscode-python

"RuntimeError: already started" after VSCode Update.

mau21mau opened this issue ยท 16 comments

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 (Viewโ†’Output, 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

I have also encountered this problem, hope it can be fixed soon.

I also came across this error after an automatic update to the extension. I tried to downgrade the extension but gave up after a few tries.

My workaround is to turn off all multi-threading in my code... hope it gets fixed soon

They are my steps to reproduce:

my environment

version: 1.46.1 (user setup)
commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.17763

I use remote WSL: Ubuntu-18.04
Python: 3.6.7 
ptvsd: 4.3.2

code

// try_multiprocess.py
from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, [1, 2, 3]))

launch.json

        {
            "name": "try multiprocess",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/try_multiprocess.py",
            "console": "integratedTerminal",
            "justMyCode": false,
        }

error

run by debug and get errors as below

$ env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /usr/bin/python3 /home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 53608 /home/noymer/program/sandbox/try_multiprocess.py 
E00000.214: Exception escaped from start_client
            
            Traceback (most recent call last):
              File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started
            

E00000.223: Exception escaped from start_client
            
            Traceback (most recent call last):
              File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started
            

E00000.232: Exception escaped from start_client
            
            Traceback (most recent call last):
              File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started
            

E00000.248: Exception escaped from start_client
            
            Traceback (most recent call last):
              File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started
            

E00000.259: Exception escaped from start_client
            
            Traceback (most recent call last):
              File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started
            

Traceback (most recent call last):
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/ptvsd_launcher.py", line 48, in <module>
    main(ptvsdArgs)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
    run()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/noymer/program/sandbox/try_multiprocess.py", line 7, in <module>
    with Pool(5) as p:
  File "/usr/lib/python3.6/multiprocessing/context.py", line 119, in Pool
    context=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__
    self._repopulate_pool()
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_pool
    self._wrap_exception)
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 255, in _repopulate_pool_static
    w.start()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.6/multiprocessing/context.py", line 277, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 66, in _launch
    self.pid = os.fork()
  File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
    self.start()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
    raise RuntimeError('already started')
RuntimeError: already started
Traceback (most recent call last):
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/ptvsd_launcher.py", line 48, in <module>
    main(ptvsdArgs)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
    run()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/noymer/program/sandbox/try_multiprocess.py", line 7, in <module>
    with Pool(5) as p:
  File "/usr/lib/python3.6/multiprocessing/context.py", line 119, in Pool
    context=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__
    self._repopulate_pool()
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_pool
    self._wrap_exception)
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 255, in _repopulate_pool_static
    w.start()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.6/multiprocessing/context.py", line 277, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 66, in _launch
Traceback (most recent call last):
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/ptvsd_launcher.py", line 48, in <module>
    self.pid = os.fork()
  File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2427, in settrace_forked
    main(ptvsdArgs)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
    run()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
    patch_multiprocessing=True,
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2179, in settrace
    runpy.run_path(target, run_name='__main__')
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
    wait_for_ready_to_run,
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2230, in _locked_settrace
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/noymer/program/sandbox/try_multiprocess.py", line 7, in <module>
    debugger.connect(host, port)  # Note: connect can raise error.
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 1060, in connect
    with Pool(5) as p:
  File "/usr/lib/python3.6/multiprocessing/context.py", line 119, in Pool
    context=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__
    s = start_client(host, port)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 136, in _start_client
    self._repopulate_pool()
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_pool
    self._wrap_exception)
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 255, in _repopulate_pool_static
    return start_client(daemon, h, p)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/log.py", line 110, in g
    w.start()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 105, in start
Traceback (most recent call last):
    return f(*args, **kwargs)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/ptvsd_launcher.py", line 48, in <module>
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/pydevd_hooks.py", line 74, in start_client
    self._popen = self._Popen(self)
  File "/usr/lib/python3.6/multiprocessing/context.py", line 277, in _Popen
    sock, start_session = daemon.start_client((host, port))
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 214, in start_client
    main(ptvsdArgs)
    return Popen(process_obj)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    with self.started():
  File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
    run()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
    self._launch(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 66, in _launch
    return next(self.gen)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
    self.pid = os.fork()
  File "/home/noymer/.vscode-server/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
    runpy.run_path(target, run_name='__main__')
    self.start()
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    raise RuntimeError('already started')
RuntimeError: already started
    _on_forked_process()
  File "/home/noymer/.vscode-server/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
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    pydevd.settrace_forked()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2427, in settrace_forked
    exec(code, run_globals)
  File "/home/noymer/program/sandbox/try_multiprocess.py", line 7, in <module>
    with Pool(5) as p:
  File "/usr/lib/python3.6/multiprocessing/context.py", line 119, in Pool
    context=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__
    self._repopulate_pool()
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_pool
    self._wrap_exception)
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 255, in _repopulate_pool_static
    patch_multiprocessing=True,
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2179, in settrace
    w.start()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 105, in start
    wait_for_ready_to_run,
    self._popen = self._Popen(self)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/_vendored/pydevd/pydevd.py", line 2230, in _locked_settrace
  File "/usr/lib/python3.6/multiprocessing/context.py", line 277, in _Popen
Error in atexit._run_exitfuncs:
    return Popen(process_obj)
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
  File "/usr/lib/python3.6/multiprocessing/util.py", line 319, in _exit_function
    self._launch(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 66, in _launch
    p.join()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 122, in join
    self.pid = os.fork()
    assert self._parent_pid == os.getpid(), 'can only join a child process'
  File "/home/noymer/.vscode-server/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
AssertionError: can only join a child process
    _on_forked_process()
  File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
    self.start()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
    raise RuntimeError('already started')
RuntimeError: already started
Traceback (most recent call last):
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/ptvsd_launcher.py", line 48, in <module>
    main(ptvsdArgs)
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 432, in main
    run()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/usr/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/noymer/program/sandbox/try_multiprocess.py", line 7, in <module>
    with Pool(5) as p:
  File "/usr/lib/python3.6/multiprocessing/context.py", line 119, in Pool
    context=self.get_context())
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 175, in __init__
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/util.py", line 319, in _exit_function
    self._repopulate_pool()
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_pool
    self._wrap_exception)
  File "/usr/lib/python3.6/multiprocessing/pool.py", line 255, in _repopulate_pool_static
    p.join()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 122, in join
    w.start()
    assert self._parent_pid == os.getpid(), 'can only join a child process'
  File "/usr/lib/python3.6/multiprocessing/process.py", line 105, in start
AssertionError: can only join a child process
    self._popen = self._Popen(self)
  File "/usr/lib/python3.6/multiprocessing/context.py", line 277, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 66, in _launch
    self.pid = os.fork()
  File "/home/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/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/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 110, in started
    self.start()
  File "/home/noymer/.vscode-server/extensions/ms-python.python-2020.6.89148/pythonFiles/lib/python/old_ptvsd/ptvsd/daemon.py", line 145, in start
    raise RuntimeError('already started')
RuntimeError: already started
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/util.py", line 319, in _exit_function
    p.join()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 122, in join
    assert self._parent_pid == os.getpid(), 'can only join a child process'
AssertionError: can only join a child process
Terminated

Though I don't understand precisely, @int19h says as this link,
microsoft/ptvsd#2129 (comment)

And the recent commit changes around of optin and optout of DebugAdapterFactory, PtvsdWheels37
650e4a9

So this commit will be the cause.

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!)

To work around without insiders build, please add the following to your settings.json:

    "python.experiments.optInto": [
        "DebugAdapterFactory - experiment",
        "PtvsdWheels37 - experiment"
    ],

To be clear, this is still a bug, and the above is a temporary workaround. We're investigating the root cause.

This should now be fixed. Can you please try restarting VSCode, and see if everything works for you now?

Thank you @int19h

At the same situation as #12481 (comment) , after restarting VSCode, the code is executed without the problem.

But after finishing the program, errors Server[6] disconnected unexpectedly Server[pid=5450] disconnected unexpectedly appear.
(It's after finishing the code, so I can use remote debugging)
image

Can you please file a separate issue at https://github.com/microsoft/debugpy ?

I have posted a issue
microsoft/debugpy#303

Thank you for your quick reply and fix @int19h !

Thanks! The fix was courtesy of @karthiknadig :)

Thank you @karthiknadig !

Interestingly, updating my insiders version (1.47.0-insiders?) and any related extensions which had an update did not solve the issue for me.

Adding the workaround suggested by @int19h into the settings.json file did solve my issue. I have multiprocessing enabled again in my code without an "already started" runtime error. Thanks :)

@garrickbrazil Sorry, I wasn't clear - I was referring to the insiders build of the Python extension, which is orthogonal to stable/insiders build of VSCode itself.

You shouldn't need it anymore, though, or anything special in settings.json - the stable version of the extension should be working correctly now out of the box. Is that not the case for you?

@int19h You are correct. I have just removed the options for "python.experiments.optInto" from my settings.json (which solved the issue originally for me) and my multiprocessing code still works! Great, thank you!

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