Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The answer is that the multiprocessing module forks a completely different process with its own stdout... So your application is running just as you wrote it:</p> <ol> <li>You start up the application in your terminal window.</li> <li>You click on the Run button in your browser which does a GET on /run</li> <li>You see the output of the current process in your terminal window, "Starting.."</li> <li>A new process is started, MyProc with its own stdout and stderr.</li> <li>MyProc prints to its stdout (which goes nowhere), 'Starting long process..'.</li> <li>The very moment MyProc starts up, your app prints to stdout, "After start." since it was not told to wait for any kind of response from MyProc before doing so.</li> </ol> <p>What you need is to implement a Queue that communicates back and forth between your main application's process and the forked process. There's some multiprocessing-specific examples on how to do that here:</p> <p><a href="http://www.ibm.com/developerworks/aix/library/au-multiprocessing/" rel="nofollow">http://www.ibm.com/developerworks/aix/library/au-multiprocessing/</a></p> <p>However, that article (like most articles from IBM) is kind of deep and overly complicated... You might want to take a look at a simpler example of how to use the "regular" Queue module (it is pretty much identical to the one included in multiprocessing):</p> <p><a href="http://www.artfulcode.net/articles/multi-threading-python/" rel="nofollow">http://www.artfulcode.net/articles/multi-threading-python/</a></p> <p>The most important concepts to understand are how to shuffle data between processes using the Queue and how to use join() to wait for a response before proceeding.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload