Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using Twisted for this sounds like it makes sense. The low-level API that supports running processes in Twisted is <a href="http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorProcess.html" rel="nofollow">reactor.spawnProcess</a>. Some examples of its usage are given in the <a href="http://twistedmatrix.com/documents/current/core/howto/process.html" rel="nofollow">process howto</a> document.</p> <p>This API is well suited for dealing with many long running processes, and as with all I/O APIs in Twisted, it works well when combined with another event source, such as <a href="http://twistedmatrix.com/documents/current/web/howto/web-in-60/index.html" rel="nofollow">a web server</a> users can use to request new processes be started up.</p> <p><code>reactor.spawnProcess</code> is more like the standard library subprocess module than like the <code>multiprocessing</code> package. It gives you a way to launch a child process running a particular executable, with particular arguments, etc. It does not provide a high-level API for running a particular Python function in another process. However, it's not too hard to build such a thing (at least for a particular case). Consider this approach:</p> <pre><code>from sys import executable from os import environ from twisted.internet import reactor implementation = """\ from yourapp import somefunction somefunction() """ reactor.spawnProcess(executable, [executable, "-c", implementation], env=environ) reactor.run() </code></pre> <p>This just launches a new Python interpreter (whichever one you happen to be running) and uses the -c option to specify a program on the command line for it to run.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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