changeset 36400:066e6a9d52bb

sshpeer: make pipe polling code more explicit "hasbuffer" is a property on our special bufferedinputpipe class. When reading this code, I thought it might have had something special to do properties on built-in types. But "hasbuffer" doesn't appear in the CPython code base for either 2.7 or 3.7, so the answer is no. Let's make the code more explicit about the fact that it deals with our special bufferedinputpipe type. Differential Revision: https://phab.mercurial-scm.org/D2382
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 21 Feb 2018 13:08:55 -0800
parents 02782e6e2c38
children 11ba1a96f946
files mercurial/sshpeer.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/sshpeer.py	Mon Feb 19 13:20:17 2018 -0800
+++ b/mercurial/sshpeer.py	Wed Feb 21 13:08:55 2018 -0800
@@ -65,8 +65,11 @@
 
         (This will only wait for data if the setup is supported by `util.poll`)
         """
-        if getattr(self._main, 'hasbuffer', False): # getattr for classic pipe
-            return (True, True) # main has data, assume side is worth poking at.
+        if (isinstance(self._main, util.bufferedinputpipe) and
+            self._main.hasbuffer):
+            # Main has data. Assume side is worth poking at.
+            return True, True
+
         fds = [self._main.fileno(), self._side.fileno()]
         try:
             act = util.poll(fds)