forking and multiple executions of code

Jack Diederich jack at performancedrivers.com
Wed May 14 02:29:50 EDT 2003


On Tue, May 13, 2003 at 10:38:01PM -0700, Roy S. Rapoport wrote:
> Given output to terminal and tasks 1...x 
> it will execute task N 2^(N-1) times (so one task is executed once,
> and one task is executed 2^(x-1) times)
> Given output to file and tasks 1...x
> It will execute *all* tasks 2^x times
> 
> And I have no clue why.  

The behavior should give you a clue.
After the process is forked, the main loop is forked too.
When the forked processes return they continue executing the loop where
you left off.

Be very happy you didn't test it with a large list the first time around ;)

-jack





More information about the Python-list mailing list