Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2296

Re: multiprocessing Pool.imap broken?

References <AANLkTinoHq9+E_+Q5Fbv7=6uihw0965GbFr--EPgckxW@mail.gmail.com> <AANLkTin6iLF4EBSt+FdR+qbdPWB8woxb6i8SYgdexaCj@mail.gmail.com> <AANLkTimckqBVed4uTVEDdxDva6bf+7x0c1ztWiwNvi5V@mail.gmail.com>
From Yang Zhang <yanghatespam@gmail.com>
Date 2011-03-31 11:47 -0700
Subject Re: multiprocessing Pool.imap broken?
Newsgroups comp.lang.python
Message-ID <mailman.41.1301597246.2990.python-list@python.org> (permalink)

Show all headers | View raw


My self-reply tried to preempt your suggestion :)

On Wed, Mar 30, 2011 at 12:12 AM, kyle.j.conroy@gmail.com
<kyle.j.conroy@gmail.com> wrote:
> Yang,
>
> My guess is that you are running into a problem using multiprocessing with
> the interpreter. The documentation states that Pool may not work correctly
> in this case.
>>
>> Note: Functionality within this package requires that the __main__ method
>> be importable by the children. This is covered in Programming guidelines
>> however it is worth pointing out here. This means that some examples, such
>> as the multiprocessing.Pool examples will not work in the interactive
>> interpreter.
>
> Hope this helps,
>
> Kyle
>
>
> On Tue, Mar 29, 2011 at 6:51 PM, Yang Zhang <yanghatespam@gmail.com> wrote:
>>
>> On Tue, Mar 29, 2011 at 6:44 PM, Yang Zhang <yanghatespam@gmail.com>
>> wrote:
>> > I've tried both the multiprocessing included in the python2.6 Ubuntu
>> > package (__version__ says 0.70a1) and the latest from PyPI (2.6.2.1).
>> > In both cases I don't know how to use imap correctly - it causes the
>> > entire interpreter to stop responding to ctrl-C's.  Any hints?  Thanks
>> > in advance.
>> >
>> > $ python
>> > Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
>> > [GCC 4.4.3] on linux2
>> > Type "help", "copyright", "credits" or "license" for more information.
>> >>>> import multiprocessing as mp
>> >>>> mp.Pool(1).map(abs, range(3))
>> > [0, 1, 2]
>> >>>> list(mp.Pool(1).imap(abs, range(3)))
>> > ^C^C^C^C^\Quit
>> >
>>
>> In case anyone jumps on this, this isn't an issue with running from the
>> console:
>>
>> $ cat /tmp/go3.py
>> import multiprocessing as mp
>> print mp.Pool(1).map(abs, range(3))
>> print list(mp.Pool(1).imap(abs, range(3)))
>>
>> $ python /tmp/go3.py
>> [0, 1, 2]
>> ^C^C^C^C^C^\Quit
>>
>> (I've actually never seen the behavior described in the corresponding
>> Note at the top of the multiprocessing documentation.)
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
Yang Zhang
http://yz.mit.edu/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: multiprocessing Pool.imap broken? Yang Zhang <yanghatespam@gmail.com> - 2011-03-31 11:47 -0700

csiph-web