Start new process by function ?

G

George Sakkis

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. "
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
M

Mathias Waack

George said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,140
Members
47,755
Latest member
Grazynkaa

Latest Threads

Top