Message1666

Author pjenvey
Recipients
Date 2007-09-17.20:37:25
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The simpler solution for this is to not use a PyFile, which currently requires the use of Input/Outputstreams that cause this issue. CPython actually uses a file-like wrapper for makefile that wraps the socket object itself, and it's implemented in pure-python code: socket._fileobject. That way the file object continues using the nio channels for i/o that won't deadlock

I've attached a patch that uses the pure python socket._fileobject from CPython 2.5.1 (which also does buffering).

I haven't committed it because there's a small issue -- the parent socket passed to the _fileobject will disable itself when closed, which in turn disables the file object. That behavior breaks the testCloseSocketDoesNotCloseFile test. I added a quick hack to fix this, just to test that this solution works: I copy.copy the socket object passed to the fileobject. All the tests pass with that change, and the Client/Server test in this bug no longer deadlocks, but copy.copy there is probably evil and Alan might have a better way of managing the parent socket vs file object here

The other benefit of this change is it removes a usage of constructing a PyFile with java objects, which requires a nasty hack to the gexpose template for Pyfile's __new__. There's only a few more of these
File Added: socket_fileobject-r3478.diff
History
Date User Action Args
2008-02-20 17:17:52adminlinkissue1744567 messages
2008-02-20 17:17:52admincreate