Python multiprocessing example not working

前端 未结 5 1159
无人及你
无人及你 2020-12-03 02:02

I am trying to learn how to use multiprocessingbut I can\'t get it to work. Here is the code right out of the documentation

from multiprocessin         


        
5条回答
  •  暖寄归人
    2020-12-03 02:25

    I had the issue that multiprocessing did not work on Spyder, and always landed here. I solved it by using threading instead of multiprocessing. as described here: https://pymotw.com/2/threading/

    import threading
    def worker(num):
        """thread worker function"""
        print 'Worker: %s' % num
        return
    threads = []
    for i in range(5):
        t = threading.Thread(target=worker, args=(i,))
        threads.append(t)
        t.start()
    

提交回复
热议问题