<p>How do I implement some logic that will allow me to reproduce on Windows the functionality that I have on Linux with the <code>fork()</code> system call, using Python?</p>

<p>I'm specifically trying to execute a method on the SAPI Com component, while continuing the other logic in the main thread without blocking or waiting.</p>

[{'answer_id': 23414, 'author': 'ftdysa', 'author_id': 2016, 'author_profile': 'https://Stackoverflow.com/users/2016', 'pm_score': 0, 'selected': False, 'text': '<p>Possibly a version of spawn() for python? <a href="http://en.wikipedia.org/wiki/Spawn_(operating_system)" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Spawn_(operating_system)</a></p>\n'}, {'answer_id': 23422, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 2, 'selected': False, 'text': '<p>Have a look at the process management functions in the <a href="http://python.org/doc/2.5/lib/os-process.html" rel="nofollow noreferrer">os module</a>. There are function for starting new processes in many different ways, both synchronously and asynchronously.</p>\n\n<p>I should note also that Windows doesn\'t provide functionality that is exactly like fork() on other systems. To do multiprocessing on Windows, you will need to use the <a href="http://python.org/doc/2.5/lib/module-threading.html" rel="nofollow noreferrer">threading</a> module.</p>\n'}, {'answer_id': 23510, 'author': 'Eli Courtwright', 'author_id': 1694, 'author_profile': 'https://Stackoverflow.com/users/1694', 'pm_score': 2, 'selected': False, 'text': '<p>In addition to the process management code in the os module that Greg pointed out, you should also take a look at the threading module:\n<a href="https://docs.python.org/library/threading.html" rel="nofollow noreferrer">https://docs.python.org/library/threading.html</a></p>\n<pre class="lang-py prettyprint-override"><code>    from threading import Thread\n    \n    def separate_computations(x, y):\n        print sum(x for i in range(y))  # really expensive multiplication\n    \n    Thread(target=separate_computations, args=[57, 83]).start()\n\n    print &quot;I\'m continuing while that other function runs in another thread!&quot;\n</code></pre>\n'}, {'answer_id': 25117, 'author': 'Daren Thomas', 'author_id': 2260, 'author_profile': 'https://Stackoverflow.com/users/2260', 'pm_score': 2, 'selected': False, 'text': '<p>You might also like using the processing module (<a href="http://pypi.python.org/pypi/processing" rel="nofollow noreferrer">http://pypi.python.org/pypi/processing</a>). It has lot\'s of functionality for writing parallel systems with the same API as the threading module...</p>\n'}, {'answer_id': 52191, 'author': 'RyanBrady', 'author_id': 2555, 'author_profile': 'https://Stackoverflow.com/users/2555', 'pm_score': 2, 'selected': False, 'text': "<p>The Threading example from Eli will run the thread, but not do any of the work after that line.  </p>\n\n<p>I'm going to look into the processing module and the subprocess module.  I think the com method I'm running needs to be in another process, not just in another thread.</p>\n"}, {'answer_id': 170387, 'author': 'Hugh Allen', 'author_id': 15069, 'author_profile': 'https://Stackoverflow.com/users/15069', 'pm_score': 3, 'selected': False, 'text': '<p><code>fork()</code> <em>has</em> in fact been duplicated in Windows, under <a href="https://en.wikipedia.org/wiki/Cygwin" rel="nofollow noreferrer">Cygwin</a>, but it\'s pretty hairy.</p>\n\n<blockquote>\n  <p>The fork call in Cygwin is particularly interesting because it does not map well on top of the Win32 API. This makes it very difficult to implement correctly.</p>\n</blockquote>\n\n<p>See the <a href="http://cygwin.com/cygwin-ug-net/highlights.html#ov-hi-process" rel="nofollow noreferrer">The Cygwin User\'s Guide</a> for a description of this hack.</p>\n'}, {'answer_id': 6020663, 'author': 'kanaka', 'author_id': 471795, 'author_profile': 'https://Stackoverflow.com/users/471795', 'pm_score': 4, 'selected': False, 'text': '<p>Use the python <a href="http://docs.python.org/library/multiprocessing.html" rel="noreferrer">multiprocessing module</a> which will work everywhere.</p>\n\n<p>Here is a <a href="http://www.ibm.com/developerworks/aix/library/au-multiprocessing/" rel="noreferrer">IBM developerWords article</a> that shows how to convert from os.fork() to the multiprocessing module.</p>\n'}]
['https://Stackoverflow.com/questions/23397', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2555/']