[Web-SIG] Returned application object and fileno.

Alan Kennedy py-web-sig at xhaus.com
Wed Sep 1 12:59:33 CEST 2004


[Alan Kennedy]
>> Problem is that jython doesn't support file descriptors, or the 
>> fileno() method. If you invoke fileno() on an org.python.core.PyFile, 
>> you get an Py.IOError("fileno() is not supported in jpython") exception.

[Andrew Eland]
> I guess the fileno() method could be renamed something like os_file() or 
> os_stream(). CPython could return a file descriptor, Jython could return 
> something like a java.nio.Channel, IronPython could return a 
> System.IO.Stream, or something like that.

Hmm, I'm not sure I understand what you are saying here Andrew.

The use-case we're trying to cover is where the application wants to 
return a file-like object to the WSGI server/framework. The applications 
intention should be that the contents of the file-like object, from the 
current file-pointer onwards, should be transferred to the return socket 
for the HTTP request.

On jython, and I'm guessing on ironpython, file-like objects don't have 
a fileno() method, or an os_file() method or an os_stream() method. They 
just have file like methods, e.g. read(), readline(), write(), etc.

What we need is a way for the application to return a file-like object, 
in a platform-independent way, so that whatever platform/framework the 
application is running in can

1. Simply read the file contents and transfer that back to the user
2. Possibly do so using a high-performance channel or stream.

Regards,

Alan.


More information about the Web-SIG mailing list