Truncated file without unbuffered mode

Fuzzyman fuzzyman at gmail.com
Tue Mar 15 08:04:10 EST 2005


I use a simple python script to monitor downloads from my website.
http://www.voidspace.org.uk/python/cgi.shtml#downman

It serves the file in a loop using our old friend :

``sys.stdout.write(chunk)``

(After sending the relevant headers with filename and filesize of
course).

I am testing this locally under windows using Xitami as localhost. If I
run in unbuffered mode (shebang line ``#!/usr/bin/python -u``) it works
fine. Without unbuffered mode (shebang line ``#!/usr/bin/python``) it
truncates the file.

This happens even if I add ``sys.stdout.flush()`` into the loop.

Does anyone know why this might happen ?

Regards,


Fuzzy
http://www.voidspace.org.uk/python/index.shtml




More information about the Python-list mailing list