forked processes and testing

Terry Reedy tjreedy at udel.edu
Wed Sep 12 16:51:09 EDT 2012


On 9/12/2012 6:20 AM, andrea crotti wrote:
> I wrote a decorator that takes a function, run it in a forked process
> and return the PID:

This strikes me as an abuse of the decorator syntax.

@wrap
def f(): pass

is just syntactic sugar for

def f(): pass
f = wrap(f)

but that is not what you are doing.

def run_in_fork(func)

def f(): pass

run_in_fork(f)

would let you test run_in_fork with simple test oriented functions and 
separately test your real functions without the complication of the fork 
process.

My 2 cents anyway.

-- 
Terry Jan Reedy




More information about the Python-list mailing list