creating tar file and streaming it over HTTP?

pbienst peter.bienstman at gmail.com
Wed Jan 6 17:39:08 CET 2010


Thanks for the tip! It doesn't change anything, though, so I've
debugged this a little bit further. The problem seems to be that the
receiving end (wsgi server) does not see the end of the data:

            socket = environ["wsgi.input"]
            while True:
                sys.stderr.write("before")
                chunk = socket.read(4096)
                sys.stderr.write("after")
                if not chunk:
                    sys.stderr.write("done")
                    break
                sys.stderr.write(chunk)

There is data from the tar file being printed, but in the end it hangs
in the 'before' statement, and never gets to 'done'. I tried flushing
the fileobj created by makefile(), but that doesn't seem to help.
There is also no environ["CONTENT_LENGTH"] that I can use to detect
the end of the stream.

I'm probably missing something basic here...



More information about the Python-list mailing list