[ACCEPTED]-What's the best way to duplicate fork() in windows?-fork

Accepted answer
Score: 18

Use the python multiprocessing module which will work everywhere.

Here 2 is a IBM developerWords article that shows how to convert from os.fork() to 1 the multiprocessing module.

Score: 10

fork() has in fact been duplicated in Windows, under 6 Cygwin, but it's pretty hairy.

The fork call in 5 Cygwin is particularly interesting because 4 it does not map well on top of the Win32 3 API. This makes it very difficult to implement 2 correctly.

See the The Cygwin User's Guide for a description of 1 this hack.

Score: 3

Have a look at the process management functions 7 in the os module. There are function for starting 6 new processes in many different ways, both 5 synchronously and asynchronously.

I should 4 note also that Windows doesn't provide functionality 3 that is exactly like fork() on other systems. To 2 do multiprocessing on Windows, you will 1 need to use the threading module.

Score: 3

In addition to the process management code 3 in the os module that Greg pointed out, you 2 should also take a look at the threading 1 module: https://docs.python.org/library/threading.html

    from threading import Thread
    def separate_computations(x, y):
        print sum(x for i in range(y))  # really expensive multiplication
    Thread(target=separate_computations, args=[57, 83]).start()

    print "I'm continuing while that other function runs in another thread!"
Score: 3

The Threading example from Eli will run 5 the thread, but not do any of the work after 4 that line.

I'm going to look into the processing 3 module and the subprocess module. I think 2 the com method I'm running needs to be in 1 another process, not just in another thread.

Score: 2

You might also like using the processing 3 module (http://pypi.python.org/pypi/processing). It has lot's of functionality 2 for writing parallel systems with the same 1 API as the threading module...

Score: 0

Possibly a version of spawn() for python? http://en.wikipedia.org/wiki/Spawn_(operating_system)


More Related questions