[Twisted-Python] Processes in Twisted, only possible to run external prog?
glyph at divmod.com
glyph at divmod.com
Fri Aug 29 07:35:24 MDT 2008
On 09:06 am, gabriel.rossetti at arimaz.com wrote:
>http://www.biais.org/blog/index.php/2007/01/23/19-python-threads-and-
>oschdir
>http://bugs.python.org/issue1367
>
>so I need to use processes instead, as they each have their own current
>dir. The thing is that from what I understand, Twisted's process API is
>intended to be used with external executables only, correct? I wasn' t
>able to fins anything that allowed me to do stuff like I would using
>fork(). Should I just use python's fock() instead? Is it safe with
>Twisted?
As it happens, "python" is an "external executable". Here's an example
of spawning it in such a way as to make sure that sys.path is set
properly:
http://divmod.org/trac/browser/trunk/Epsilon/epsilon/process.py#L7
However, Wine is also an external process. Perhaps you just want to
spawn the Wine command-line using spawnProcess using the 'path'
parameter set to a directory that you have created in the main process,
then clean it up when the process exits?
http://twistedmatrix.com/documents/8.1.0/api/twisted.internet.interfaces.IReactorProcess.spawnProcess.html
Using fork() in Python has a lot of confusing issues associated with it
unless you're going to exec() immediately afterwards. You probably want
to stick to one of these other approaches.
More information about the Twisted-Python
mailing list