This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author v+python
Recipients v+python
Date 2010-11-24.07:56:18
SpamBayes Score 5.1020854e-11
Marked as misclassified No
Message-id <1290585381.55.0.0184871541809.issue10482@psf.upfronthosting.co.za>
In-reply-to
Content
So I've experimented a bit, and it looks like simply exposing ._readerthread as an external API would handle the buffered case for stdout or stderr.  For http.server CGI scripts, I think it is fine to buffer stderr, as it should not be a high-volume channel... but not both stderr and stdout, as stdout can be huge.  And not stdin, because it can be huge also.

For stdin, something like the following might work nicely for some cases, including http.server (with revisions):

    def _writerthread(self, fhr, fhw, length):
        while length > 0:
            buf = fhr.read( min( 8196, length ))
            fhw.write( buf )
            length -= len( buf )
        fhw.close()

When the stdin data is buffered, but the application wishes to be stdout centric instead of stdin centric (like the current ._communicate code), a variation could be made replacing fhr by a data buffer, and writing it gradually (or fully) to the pipe, but from a secondary thread.

Happily, this sort of code (the above is extracted from a test version of http.server) can be implemented in the server, but would be more usefully provided by subprocess, in my opinion.

To include the above code inside subprocess would just be a matter of tweaking references to class members instead of parameters.
History
Date User Action Args
2010-11-24 07:56:21v+pythonsetrecipients: + v+python
2010-11-24 07:56:21v+pythonsetmessageid: <1290585381.55.0.0184871541809.issue10482@psf.upfronthosting.co.za>
2010-11-24 07:56:19v+pythonlinkissue10482 messages
2010-11-24 07:56:18v+pythoncreate