Create a new process to run python function

Massi massi_srb at msn.com
Wed May 5 08:56:03 EDT 2010


Hi everyone,

in my script (python 2.5 on windows xp) I need to run a simple
function in a separate process. In other words I need something
similar to the fork function under UNIX. I tried with threads:

import os, threading

def func(s) :
    print "I'm thread number "+s, os.getpid()

threading.Thread(target=func, args=("1",)).start()
threading.Thread(target=func, args=("2",)).start()

but this does not work, since the two threads share the same pid. Can
anyone give me a suggestion?
Thanks in advance.



More information about the Python-list mailing list