1

I'm playing with Python multiprocessing. But it wouldn't work on my system.

I ran the example code I found on multiprocessing page. But it just hangs there and the CPU usage is 0%. What do I do to make it work? Thanks a lot! https://docs.python.org/2/library/multiprocessing.html

from multiprocessing import Pool

def f(x):
    return x*x

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

update: just tried to run the same code in command line and get the following error message. Error Message

DeadJoker
  • 41
  • 1
  • 6
  • It works fine for me .. how are you running it? What python version? Interpreter or file? – Mick_ Aug 02 '18 at 16:24
  • 1
    I tried in both python 2.7 and 3.7, works fine here. Can you give us some context on how you are running it? – dheiberg Aug 02 '18 at 16:25
  • I'm sure the code is fine. Because it comes from the official website. There must be something wrong with my system settings. But I don't know what it is. I'm running python 3.7 with jupyter notebook on a WIndows server. – DeadJoker Aug 02 '18 at 16:44
  • @DeadJoker I don't know much about that setup, but the second answer [here](https://stackoverflow.com/questions/45719956/python-multiprocessing-attributeerror-cant-get-attribute-abc) looks like it could be useful? – dheiberg Aug 02 '18 at 16:56

0 Answers0