[Twisted-Python] Process Producer, Request Consumer
Chris Armstrong
carmstro at twistedmatrix.com
Sun Nov 18 00:32:01 MST 2001
From: Kevin Turner <acapnotic at twistedmatrix.com>
Subject: Re: [Twisted-Python] Process Producer, Request Consumer
Date: Sat, 17 Nov 2001 18:10:20 -0800
> On Sat, Nov 17, 2001 at 02:21:40PM -0600, Glyph Lefkowitz wrote:
> > On Sat, 2001-11-17 at 13:26, Kevin Turner wrote:
> > > it seems like this should be at most two lines long:
> > > 1) create Process
> > > 2) designate the web Request as a consumer of the Process.
> >
> > [...] wrong. [...] you would be abandoning any further output to that
> > webpage; the Process would take over and close it.
>
> Well, for the purposes of discussion, because I don't understand how to
> best use Process, let's say that's acceptable behavour. It's okay if
> the request is considered finished as soon as the process is. Now, how
> would I do it?
>
Didn't we come to the conclusion on IRC? I think the idea was
class WebProcess(process.Process):
def __init__(self, request):
process.Process.__init__(self)
self.request = request
def handleChunk(self, data):
self.request.write(data)
def connectionLost(self):
self.write("</body></html>")
self.request.finish()
process.Process.connectionLost(self)
and your .epy would look something like
request.write("<html><body>The output of command is:")
WebProcess(request) #you probably have to do something more than this..
#register it with the mainloop somehow?
Note that this code is guaranteed to be incomplete, but I think that's the
general idea.
--
<radix> I was drinking tea before this job
--
Chris Armstrong
<<< radix at twistedmatrix.com >>>
http://twistedmatrix.com/users/carmstro.twistd/
More information about the Twisted-Python
mailing list