-
Notifications
You must be signed in to change notification settings - Fork 67
when I debug, I meet: Runtime Error: Already started in multiprocess #1761
Comments
@civilman628 Which config from the launch,json are you using? I don't see |
@karthiknadig This is my question as well, in order to use python virtual environment for multiprocessing. How do i need to change launch.json? currently, only settings.json has my python path "python.pythonPath": "venv/bin/python" |
Ah I see, for any configuration you are using add the {
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"subProcess": true,
}, As long as the venv pat is set in the settings this should be good. In your code, where you add these lines matters. Can you share your code? Are you using import multiprocessing
multiprocessing.set_start_method('spawn', True) |
I do not use ptvsd.enable_attach() I can't paste all my code here, but here is the top part our my python file that i need to run, i am not sure it is enough.
There is an init.py file in the same folder as of above file that contain the lines below
I should add the 2 lines below in which file and which section?
|
I am assuming you are using the following configuration to launch: {
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"subProcess": true,
}, It should go before anything thing gets imported. Try adding it before |
i add "subProcess": true, to the json file and add these 2 lines at the very top of the code, but the error is the same. |
I am running my python code in a Ubuntu VM that is hosted by windows 10. Is this config impact multiprocess? |
No, it should not. Really what is happening is somewhere some library is calling @fabioz Any ideas on how we can get the stack from where the fork is being called? looks like |
Note that if |
I just have a check, my code does not has |
You can try to do (at the start of your code) something as:
do a regular (non-debug) run and see if that's hit (it's probable that in this case the Python The workaround in this case would be starting without debugging and do a remote attach directly in the subprocess (we're currently working on adding the |
My python code has no issue to run in the terminal, which is out of VS code. I do not need to add the code above or these 2 lines. I only meet errors when debugging in vs code. |
May I know if there is any rough estimation that how long this issue will be fixed? |
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
},
]
} |
@naefl, can you tell more about the code that you're hitting this issue on - in particular, whether you're using |
Hi @int19h, thanks for looking into this - as said, using sklearn which utilizes multiprocessing. I hit the error when running any code that involves sklearn. |
My apologies, I didn't notice that part. Did you get a chance to try Broadly speaking, these fork-related issues will be resolved once we complete #1706, which is in progress right now. Until then, we can only try to find workarounds for any particular library or scenario. |
I'll give it a try, thanks! Any ideas on order of magnitude of timeline, weeks, months? I think it's important highlighting that Sklearn is probably the most used Machine Learning library, and with lots of VSCode's changes targeted towards Data Scientists I assume that a lot of users will run into this problem and give up before they end up reporting their issue here. Either way, thanks a lot for all the awesome work you're doing. |
Same error with import multiprocessing
multiprocessing.set_start_method('spawn', True) File "/root/.vscode-server-insiders/extensions/ms-python.python-2019.10.44104/pythonFiles/lib/python/old_ptvsd/ptvsd/multiproc.py", line 182, in notify_root
conn.connect(('localhost', options.subprocess_notify))
ConnectionRefusedError: [Errno 111] Connection refused
[1] 2400 terminated env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /opt/conda/bin/python --default |
#1878 is the new multiproc implementation that should fix this issue. |
@int19h which version will include this fix? |
@civilman628 The next alpha of ptvsd 5.0 will have it. |
Environment data
same as #1443
i already add these 2 lines in my code:
my launch.json:
settings.json
do i need to modify launch.json? When I debug, I can see my python venv in effect.
The text was updated successfully, but these errors were encountered: