Start new process by function ?
Mathias Waack
M.Waack at gmx.de
Thu Mar 10 17:18:18 EST 2005
George Sakkis wrote:
> Is it possible to start a new process by specifying a function call
> (in similar function to thread targets) instead of having to write
> the function in a separate script and call it through os.system or
> os.spawn* ? That is, something like
>
> def foo(): pass
> os.spawn(foo)
Just starting is easy:
def spawn(f):
if os.fork() == 0:
f()
sys.exit(0)
But I'd expect you would like to get some return values from f...
Mathias
More information about the Python-list
mailing list