[Twisted-Python] More general process.Process class

Jean-Paul Calderone exarkun at divmod.com
Wed Jul 4 08:21:28 MDT 2007


On Wed, 04 Jul 2007 16:13:14 +0200, Markus Schiltknecht <markus at bluegap.ch> wrote:
>Hi,
>
>I'm currently fiddling with spawnProcess() and such, trying to stream it's 
>output to somewhere else. In a first attempt, I've tried to cache the data 
>in the ProcessProtocol's outReceived() call.
>
>Then, I've realized, that twisted already has quite nice abstractions of 
>Producers and Consumers. I would like to use them, as they seem to fit 
>nicely.
>
>And in my case, it would even make much sense to *not* read all the data 
>from the process, but leave it there, waiting on the file descriptor, until 
>I'm ready to process the data.
>
>Unfortunately, AFAICT the producers attached to the process - namely the 
>ProcessReader() instances created by process.Process - are hard wired to the 
>ProcessProtocol's dataReceived() method. While I would like to use these 
>producers directly, instead of providing such a ProcessProtocol.
>
>I'm thinking about ripping out the protocol handling from the 
>process.Process class. Instead let process.Process return a list of 
>producers and consumers in self.pipes, as requested. Then let another 
>wrapper class bridge between those and the ProcessProtocol.
>
>Comments?

Do you need more granularity than Process.pauseProducing/resumeProducing
provide?

Aside from that, purely as a point of procedure, any changes you make to
Process at the moment are likely to conflict with a development branch
which is currently outstanding.  You might want to look at that or help
get it merged before starting on any changes of your own.

Jean-Paul




More information about the Twisted-Python mailing list