David Reid wrote:
Ok, while True is bad and blocking. I think you should look at twisted.web2.static.FileSaver, if it doesn' perform a function close enough to what you want it is a good example of the right way to handle uploaded files as far as reading. (Hint it's to use things in the twisted.web2.stream library) I expect your problems will go away
Thanks for pointing this out. The stream classes look really cool.
So I replaced my bad 'while True' blocking code with the following:
filestream = stream.FileStream(file) dest = os.path.join(SAVEDIR,filename) destfile = os.fdopen(os.open(dest, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0644), 'w', 0) stream.readIntoFile(filestream, destfile)
And this works great -- but only for files smaller than 10M. It looks like files >10M still produce the hang -- same behavior as before.
but you might still want to file a documentation enhancement bug stating that how to do this kind of thing is completely undocumented.
I'll file tickets for both of these, to try to stop cluttering the mailing list with these issues.
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
On Tue, 27 Jun 2006 13:48:58 -0700 (PDT), Lenny G Arbage email@example.com wrote:
The stream classes look really cool.
Please note that the stream classes will be going away before final release of web2. This is one of the consequences of its instability :). Twisted has other mechanisms for dealing with objects which produce arbitrary amounts of data incrementally, though (one might say that's all Twisted *is*, in fact) and the general idea of waiting for callbacks to produce or consume data will remain.