Patchwork D2382: sshpeer: make pipe polling code more explicit

login
register
mail settings
Submitter phabricator
Date Feb. 21, 2018, 10:08 p.m.
Message ID <differential-rev-PHID-DREV-7xafasfed25wouwrc5yn-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28215/
State Superseded
Headers show

Comments

phabricator - Feb. 21, 2018, 10:08 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  "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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2382

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -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)