[Python-ideas] More general "for" loop handling
Todd
toddrjen at gmail.com
Thu Apr 30 19:13:37 CEST 2015
On Thu, Apr 30, 2015 at 6:45 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 30 April 2015 at 17:03, Stefan Behnel <stefan_ml at behnel.de> wrote:
> > Steven D'Aprano schrieb am 30.04.2015 um 13:36:
> >> "async for" hasn't proven itself yet, and you are already looking to
> >> generalise it? Shouldn't it prove itself as not a mistake first?
> >
> > Also, it should be quite possible to achieve what the OP proposed with
> > "async for" since it's in no way limited to the way asyncio handles
> things.
> > "async for" is a bit of a badly named feature, but that's intended in
> order
> > to match what people would know from other programming languages.
>
> Could you explain how?
>
> Specifically, what's the translation of
>
> from multiprocessing import Pool
>
> mypool = Pool(10, maxtasksperchild=2)
>
> mypool for item in items:
> do_something_here
> do_something_else
> do_yet_another_thing
>
> I'm assuming that's the OP's intention (it's certainly mine) is that
> the "mypool for" loop works something like
>
> def _work(item):
> do_something_here
> do_something_else
> do_yet_another_thing
> for _ in mypool.map(_work, items):
> # Wait for the subprocesses
> pass
>
Yes, thank you, that is exactly what I intended.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150430/5ade84e2/attachment.html>
More information about the Python-ideas
mailing list