By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,271 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,271 IT Pros & Developers. It's quick & easy.

Start new process by function ?

P: n/a
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)

Thanks in advance,

George
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Haiku of the day:

"A file that big? / It might be very useful / But now it is gone. "
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.