Here's an example of how to fork a process using the multiprocessing
module in Python:
main.py253 chars13 lines
In this example, a new process is created by calling Process(target=worker)
and starting it with p.start()
. The worker
function is run in the new process, which prints out its process ID using os.getpid()
. The parent process waits for the child process to finish with p.join()
.
gistlibby LogSnag