Using multiprocessing

Aaron "Castironpi" Brady castironpi at gmail.com
Fri Oct 10 22:52:19 EDT 2008


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.



More information about the Python-list mailing list