tleeuwenb...@gmail.com wrote: > I have a problem using multiprocessing in a simple way. I created a > file, testmp.py, with the following contents: > > --------------------------------------------------- > import multiprocessing as mp > > p = mp.Pool(5) > > def f(x): > return x * x > > print map(f, [1,2,3,4,5]) > print p.map(f, [1,2,3,4,5]) > > ---------------------------------------------------- > > I'm using 2.6 r26:66713, so not quite bleeding edge. > > If I run 'python2.6 testmp.py' I get errors of exactly the kind > mentioned on docs.python.org for when multiprocessing is run using the > interactive interpreter. However, I'm obviously *not* running the > interactive interpreter. > > Any suggestions?
I'm too lazy to read the docs, so I just tinkered: import multiprocessing as mp import testmp p = mp.Pool(5) def f(x): return x * x if __name__ == "__main__": print map(f, [1,2,3,4,5]) print p.map(testmp.f, [1,2,3,4,5]) -- http://mail.python.org/mailman/listinfo/python-list