Parallel crashed on python 3.6 when running in vscode debugger
See original GitHub issueMy environment is python 3.6 and I ran a simple script file like below:
from math import sqrt
from joblib import Parallel, delayed
def main():
print('simulate workers, testing parallel')
Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10))
if __name__ == '__main__':
print('simulate workers, testing parallel')
Parallel(n_jobs=2)(delayed(sqrt)(i ** 2) for i in range(10))
And facing a crash:
Below is the log details: E00001.438: Exception escaped from start_client
Traceback (most recent call last):
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/log.py", line 110, in g
return f(*args, **kwargs)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 214, in start_client
with self.started():
File "/Users/fans3210/anaconda3/envs/assignQuestion-py36/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 110, in started
self.start()
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 145, in start
raise RuntimeError('already started')
RuntimeError: already started
/Users/fans3210/anaconda3/envs/assignQuestion-py36/lib/python3.6/site-packages/joblib/externals/loky/backend/semaphore_tracker.py:74: UserWarning: semaphore_tracker: process died unexpectedly, relaunching. Some semaphores might leak. warnings.warn('semaphore_tracker: process died unexpectedly, ’ E00001.467: Exception escaped from start_client
Traceback (most recent call last):
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/log.py", line 110, in g
return f(*args, **kwargs)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 214, in start_client
with self.started():
File "/Users/fans3210/anaconda3/envs/assignQuestion-py36/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 110, in started
self.start()
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 145, in start
raise RuntimeError('already started')
RuntimeError: already started
E00001.481: Exception escaped from start_client
Traceback (most recent call last):
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/log.py", line 110, in g
return f(*args, **kwargs)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 214, in start_client
with self.started():
File "/Users/fans3210/anaconda3/envs/assignQuestion-py36/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 110, in started
self.start()
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 145, in start
raise RuntimeError('already started')
RuntimeError: already started
E00001.515: Exception escaped from start_client
Traceback (most recent call last):
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/log.py", line 110, in g
return f(*args, **kwargs)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/pydevd_hooks.py", line 74, in start_client
sock, start_session = daemon.start_client((host, port))
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 214, in start_client
with self.started():
File "/Users/fans3210/anaconda3/envs/assignQuestion-py36/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 110, in started
self.start()
File "/Users/fans3210/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 145, in start
raise RuntimeError('already started')
RuntimeError: already started
The only solution I can use is to set" “prefer = ‘threads’” in the function call. Appreciated if someone could help!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:18
Top Results From Across the Web
Debugging configurations for Python apps in Visual Studio Code
The Python extension supports debugging of several types of Python ... To initialize debug configurations, first select the Run view in the sidebar:....
Read more >VS Code Debugger not working for python - Microsoft Q&A
When VS Code was updated to 1.64.0 it seems to have broken Python debugging. Clicking on "Run Python File" works fine. Clicking on...
Read more >Debug a Parallel MPI program in Visual Studio Code - YouTube
I explain how you can debug a parallel MPI program with visual studio ( vs) code. I run it on Linux Ubuntu. For...
Read more >Debugger crashes on Python 3.6.0 : PY-48069 - YouTrack
and set breakpoint on this line, but the debug run crash with output below: /Users/xxx/.pyenv/versions/XXX-3.6/bin/python "/Users/xxx/Library/Application ...
Read more >Developing with asyncio — Python 3.11.1 documentation
By default asyncio runs in production mode. In order to ease the development asyncio has a debug mode. There are several ways to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, I saw a solution by amittleider and it worked for me. Paste it here:
Do the following to avoid the semaphore error:
import multiprocessing multiprocessing.set_start_method('spawn', True)
"subProcess": true,
and for Pytorch DataLoader function, set num_worker threads as ‘0’.Hope this helps you! It worked for me.