Message10765

Author nickmbailey
Recipients nickmbailey, zyasoft
Date 2016-02-23.23:22:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1456269772.38.0.584279416225.issue2470@psf.upfronthosting.co.za>
In-reply-to
Content
Jim pointed out that the initial diff I included breaks other tests. I modified it slightly and managed to get my example working without breaking any other tests.

diff --git a/Lib/_socket.py b/Lib/_socket.py
index 3b658e5..4b3c7df 100644
--- a/Lib/_socket.py
+++ b/Lib/_socket.py
@@ -729,6 +729,7 @@ class _realsocket(object):
         self.selectors = CopyOnWriteArrayList()
         self.options = {}  # deferred options until bootstrap
         self.peer_closed = False
+        self.channel_closed = False

         # Reference count this underlying socket
         self.open_lock = Lock()
@@ -875,12 +876,13 @@ class _realsocket(object):
         if self.connect_handlers:
             self.channel.pipeline().addLast(self.python_inbound_handler)

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

-        self.channel.closeFuture().addListener(peer_closed)
+        self.channel.closeFuture().addListener(channel_closed)

     def connect(self, addr):
         # Unwrapped sockets can immediately perform the post-connect step
@@ -1121,7 +1123,7 @@ class _realsocket(object):
         return 0

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

     can_write = _writable


I'd still like the change to be vetted though.
History
Date User Action Args
2016-02-23 23:22:52nickmbaileysetmessageid: <1456269772.38.0.584279416225.issue2470@psf.upfronthosting.co.za>
2016-02-23 23:22:52nickmbaileysetrecipients: + nickmbailey, zyasoft
2016-02-23 23:22:52nickmbaileylinkissue2470 messages
2016-02-23 23:22:51nickmbaileycreate