简体   繁体   中英

Python multiprocessing doesn't work in visual studio

I want to make something with the multiprocessing library. But when I run the following code in Visual Studio on my Windows PC, it won't stop the programming and it doesn't print anything.

import multiprocessing
import os

def test():
    print('Hello')

if __name__ == '__main__':
    p = multiprocessing.Process(target=test)
    p.start()
    p.join()

The code works if I don't have a loop at the first process

Agreed, it does not work with any example in VS 2019. This used to work 6 months ago. I recommend just starting things with a batch script.

If you run the your program without debugging (Ctrl + F5 or right click your program and "start without debugging"), the multiprocessing functions just fine. I was having the same issue in VS 2019. My guess is multi-processing debugging isn't supported in VS (it isn't in VS code from this issue in 2017 https://github.com/Microsoft/vscode-python/issues/314 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM