[Twisted-Python] Large file transfers

Paul Boehm typo at soniq.net
Fri Jul 26 08:55:33 EDT 2002


On Fri, Jul 26, 2002 at 07:41:27AM -0500, Chris Armstrong wrote:
> AFAIK, twisted.web.static _does_ do non-blocking reading, so check that out.
> I don't think anyone has implemented non-blocking writing yet. (There's some
> sort of FileWrapper protocol or somesuch IIRC, but it just assumes that
> write() won't take very long -- it's only for testing)

no it doesn't,
 f = open(self.path,'rb')
...
# return data
FileTransfer(f, size, request)
# and make sure the connection doesn't get closed
return server.NOT_DONE_YET

this is a normal file instance.. i have yet to find a way to do nonblocking
file reads.. till then i'm starting to implement a protocol which i can tell
upon initialization which parts of the file i want to have streamed.

ah, and i think twisted.web.static.FileTransfer has a bug:
you can specify where it starts reading with seek, and set an
arbitrary size.. but it read()->write()'s by
abstract.FileDescriptor.bufferSize
and then checks "if self.file.tell() == self.size:" which
won't be correct if the file is larger than the requested chunk.

  paul





More information about the Twisted-Python mailing list