[Web-SIG] WSGI and sendfile()
Andrew Eland
andrew at andreweland.org
Mon Aug 23 11:37:29 CEST 2004
The WSGI draft seems to be progressing well, it's great to see some
effort at standardisation in this area.
I had a couple of thoughts:
If write() allowed an object implementing the fileno() method as a
parameter, then an implementation is free to use the sendfile() syscall
to efficiently send the entire contents of a file descriptor to the client.
I don't know whether others think this is useful enough functionality to
warrant the extra implementation complexity.
If you ignore the possible efficiency gains, and sendfile() is emulated
by the implementation, it still reduces the amount of code that needs to
be written to serve a static file.
There's an as asymmetry in streaming. Although the use of iterators
allows a single-threaded implementation to stream a response to many
clients simultaneously with something like select(), it doesn't work the
other way around. If the only access to the request body is via the
wsgi.input stream, all reads will be blocking. Although processing many
large uploads simultaneously isn't such a common use case when
developing websites, it can be when developing web services.
-- Andrew Eland (http://www.andreweland.org)
More information about the Web-SIG
mailing list