[Twisted-Python] Re: Improving spawnProcess and friends

Nuutti Kotivuori naked at iki.fi
Sun Jul 23 16:15:49 EDT 2006

Itamar Shtull-Trauring wrote:
> On Sat, 2006-07-22 at 18:44 +0300, Nuutti Kotivuori wrote:
> ... adding factory object to process spawning ...
>> How does this sound? If nobody yells murder, I'll be starting to build
>> a rudimentary implementation of this to see how the API would
>> naturally turn out to be and then submit it here for review.
> Seems... over-engineered. I'm not sure adding a whole new object is the
> way to go on this.

A valid concern, it did cross my mind as well. However, I have yet to
think of a better way to achieve all the features that are wished
for. Any suggestions?

Anyway, I have implemented some of the changes already. The patch is
again attached to the issue. Everything is still subject to change,
however. But, this is how setting up a process would look like at the

  class MyProcessProtocolFactory(process.ProcessProtocolFactory):
      def processSetup(self, proc):
           proc.addHelper(SetuidHelper(1000, 1000))
           proc.addHelper(PTY('pty', [0, 1]))
           proc.addHelper(PassthroughFD(sys.stderr.fileno(), [2]))
           proc.addHelper(WritePipe('passphrase', [3]))

This would configure the process to have uid 1000 and gid 1000, the
executable to be started in path /tmp, file descriptors 0 and 1 would
map to a PTY on the child, which would come in as
childDataReceived('pty', data) on the process protocol, file
descriptor 2 would be the parent's stderr and file descriptor 3 would
be a write pipe by the name of passphrase, that would be written as
transport.writeToChild('passphrase', 'foobar').

This is still lacking the ability to give different protocols to
different communication channels and the chdir/chroot/whatever helper
logic is hackish.

So, feedback is very much appreciated, as always. Regardless, I'll
holler on the list again when I think of where to go next with this

-- Naked

More information about the Twisted-Python mailing list