Python-list digest, Vol 1 #12538 - 15 msgs

Frank Gibbons fgibbons at
Wed Sep 25 09:09:16 EDT 2002

Thanks for the comments, Donn. I was just about to try something like that 
myself. The toy example I posted does not do what I really want to, which 
is to avoid using a temporary file at all, and echo the output from gzip 
directly to the web browser, with appropriate content-type, of course. Your 
blocked input/output seems the way to go.

Thanks again,


At 01:26 AM 9/25/2002, you wrote:
>It isn't going to be fixed, either, because there are just some
>axiomatic truths in operation here, like "I/O buffers aren't
>infinitely elastic." Since your example doesn't do anything with
>the output, you don't have to shoot yourself in the foot this way.
>Try something like this -
>   zip_input = os.popen('gzip -c > popen.gz', 'w')
>   while 1:
>       data =
>       if not data:
>           break
>       zip_input.write(data)
>   zip_input.close()
>The main point is that this allows gzip to write directly to disk.
>If your actual application needs to process the data further at this
>point, you may read it back from disk and write to a new file if you
>like.   Otherwise, if you really want a second pipe, you have to figure
>out how to read some, write some, etc., to keep gzip's output from
>filling up while you're trying to write all its input.

PhD, Computational Biologist,
Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA 02115, USA.
Tel: 617-432-3555       Fax: 

More information about the Python-list mailing list