Message10760

Author nickmbailey
Recipients nickmbailey
Date 2016-02-19.21:04:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1455915873.17.0.469355166541.issue2470@psf.upfronthosting.co.za>
In-reply-to
Content
The following patch fixes the issue for me by setting 'self.peer_closed' earlier and returning True from '_writable' if self.peer_closed is True. I'm not 100% positive that's the correct thing to do in all cases though.

diff --git a/Lib/_socket.py b/Lib/_socket.py
index 3b658e5..f1987d5 100644
--- a/Lib/_socket.py
+++ b/Lib/_socket.py
@@ -877,6 +877,7 @@ class _realsocket(object):

         def peer_closed(x):
             log.debug("Peer closed channel %s", x, extra={"sock": self})
+            self.peer_closed = True
             self.incoming.put(_PEER_CLOSED)
             self._notify_selectors(hangup=True)

@@ -1121,7 +1122,7 @@ class _realsocket(object):
         return 0

     def _writable(self):
-        return self.channel and self.channel.isActive() and self.channel.isWritable()
+        return self.peer_closed or (self.channel and self.channel.isActive() and self.channel.isWritable())

     can_write = _writable

@@ -1176,7 +1177,6 @@ class _realsocket(object):
         if msg is _PEER_CLOSED:
             # Only return _PEER_CLOSED once
             self.incoming_head = None
-            self.peer_closed = True
         return msg

     @raises_java_exception
History
Date User Action Args
2016-02-19 21:04:33nickmbaileysetmessageid: <1455915873.17.0.469355166541.issue2470@psf.upfronthosting.co.za>
2016-02-19 21:04:33nickmbaileysetrecipients: + nickmbailey
2016-02-19 21:04:33nickmbaileylinkissue2470 messages
2016-02-19 21:04:32nickmbaileycreate