On Mar 4, 2011, at 11:08 PM, Vincent Ren wrote: > Hello, everyone, recently I am trying to learn python's > multiprocessing, but > I got confused as a beginner. > > If I run the code below: > > from multiprocessing import Pool > import urllib2 > otasks = [ > 'http://www.php.net' > 'http://www.python.org' > 'http://www.perl.org' > 'http://www.gnu.org' > ] > > def f(url): > return urllib2.urlopen(url).read() > > pool = Pool(processes = 2) > print pool.map(f, tasks)
Hi Vincent, I don't think that's the code you're running, because that code won't run. Here's what I get when I run the code you gave us: Traceback (most recent call last): File "x.py", line 14, in <module> print pool.map(f, tasks) NameError: name 'tasks' is not defined When I change the name of "otasks" to "tasks", I get the nonnumeric port error that you reported. Me, I would debug it by adding a print statement to f(): def f(url): print url return urllib2.urlopen(url).read() Your problem isn't related to multiprocessing. Good luck Philip > > > I'll receive this message: > > Traceback (most recent call last): > File "<stdin>", line 14, in <module> > File "/usr/lib/python2.6/multiprocessing/pool.py", line 148, in map > return self.map_async(func, iterable, chunksize).get() > File "/usr/lib/python2.6/multiprocessing/pool.py", line 422, in get > raise self._value > httplib.InvalidURL: nonnumeric port: '' > > > > I run Python 2.6 on Ubuntu 10.10 > > > Regards > Vincent > > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list