Using multiprocessing

nhwarriors edward.reed at gmail.com
Fri Oct 10 23:48:48 EDT 2008


On Oct 10, 10:52 pm, "Aaron \"Castironpi\" Brady"
<castiro... at gmail.com> wrote:
> On Oct 10, 3:32 pm, nhwarriors <edward.r... at gmail.com> wrote:
>
>
>
> > I am attempting to use the (new in 2.6) multiprocessing package to
> > process 2 items in a large queue of items simultaneously. I'd like to
> > be able to print to the screen the results of each item before
> > starting the next one. I'm having trouble with this so far.
>
> > Here is some (useless) example code that shows how far I've gotten by
> > reading the documentation:
>
> snip code
>
> > This works great, except that nothing can be output until everything
> > in the queue is finished. I'd like to write out the result of fac(n)
> > for each item in the queue as it happens.
>
> > I'm probably approaching the problem all wrong - can anyone set me on
> > the right track?
>
> Works fine for me.  Formatting time.clock(), with a different range:
>
> 0.00000 fac(25000) done on Process-2
> 0.09334 fac(25001) done on Process-1
> 2.25036 fac(25002) done on Process-2
> 2.41227 fac(25003) done on Process-1
> 3.57167 fac(25004) done on Process-2
>
> I'm on Win32.

Strange. I was on Win32 (Cygwin) earlier today and it was doing what I
reported above. At home on Linux, it works as I wanted and you
experienced. Must be something screwy with running it in Cygwin.

Thanks guys!



More information about the Python-list mailing list