[Twisted-Python] Serving files, again
Christopher Armstrong
radix at twistedmatrix.com
Wed Feb 26 17:23:44 EST 2003
On Wed, Feb 26, 2003 at 02:50:31PM -0500, Jp Calderone wrote:
> On Wed, Feb 26, 2003 at 07:51:35PM +0000, Clark C. Evans wrote:
> > On Wed, Feb 26, 2003 at 07:20:02PM +0000, Clark C. Evans wrote:
> > |
> > | I don't know if this is your question; but I'd return the contents
> > | of file.txt when the file size is less than a pre-defined size, say 32K.
> > | Beyond that, the file should be DEFERRED into a thread which sends
> > | the file a chunk at a time. Further, it'd be cool if I could
> > | specify in the request object if the response should be compressed
> > | via gzip.
> >
> > Actually, shouldn't it always be deferred? The file system may
> > be writing at the time (via another thread) so doing a file read
> > (even for a tiny file) at this point could cause significant lag
> > or am I completely mis-understanding this whole async-stuff?
>
> We usually consider IO on local fixed disks to be fast enough. In any
> case, select() in POSIX tells you that files are always ready for reading,
> so being smarter about it requires using a different mechanism (which is
> entirely possible, but requires a different reactor, not to mention platform
> support).
>
> BTW, deferring to a thread would not be the way to go. Something similar
> to twisted.spread.util.Pager would probably be appropriate, or maybe
> something that implements IProducer. Or maybe just a chain of Deferreds :)
> No need to go into threads for this, though.
static.File already reads/writes in chunks, and it uses Producers.
--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | Release Manager, Twisted Project
---------+ http://twistedmatrix.com/users/radix.twistd/
More information about the Twisted-Python
mailing list