comparison mercurial/sshpeer.py @ 34105:c037fd655b47

ssh: fix flakey ssh errors on BSD systems There's been a persistent issue with flakiness on BSD systems (like OSX) where the 'no suitable response from remote hg' message would sometimes not appear. This was caused by one of the earlier calls failing with a "IOError: Broken pipe". Catching those errors and printing the same message removes the flakiness. Differential Revision: https://phab.mercurial-scm.org/D687
author Durham Goode <durham@fb.com>
date Mon, 11 Sep 2017 15:59:18 -0700
parents dedab036215d
children 2844c4bd5a39
comparison
equal deleted inserted replaced
34104:f698bb31bdfb 34105:c037fd655b47
201 201
202 self._pipei = util.bufferedinputpipe(self._pipei) 202 self._pipei = util.bufferedinputpipe(self._pipei)
203 self._pipei = doublepipe(self.ui, self._pipei, self._pipee) 203 self._pipei = doublepipe(self.ui, self._pipei, self._pipee)
204 self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee) 204 self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee)
205 205
206 # skip any noise generated by remote shell 206 def badresponse():
207 self._callstream("hello") 207 self._abort(error.RepoError(_('no suitable response from '
208 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40))) 208 'remote hg')))
209
210 try:
211 # skip any noise generated by remote shell
212 self._callstream("hello")
213 r = self._callstream("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
214 except IOError:
215 badresponse()
216
209 lines = ["", "dummy"] 217 lines = ["", "dummy"]
210 max_noise = 500 218 max_noise = 500
211 while lines[-1] and max_noise: 219 while lines[-1] and max_noise:
212 l = r.readline() 220 try:
213 self._readerr() 221 l = r.readline()
214 if lines[-1] == "1\n" and l == "\n": 222 self._readerr()
215 break 223 if lines[-1] == "1\n" and l == "\n":
216 if l: 224 break
217 self.ui.debug("remote: ", l) 225 if l:
218 lines.append(l) 226 self.ui.debug("remote: ", l)
219 max_noise -= 1 227 lines.append(l)
228 max_noise -= 1
229 except IOError:
230 badresponse()
220 else: 231 else:
221 self._abort(error.RepoError(_('no suitable response from ' 232 badresponse()
222 'remote hg')))
223 233
224 self._caps = set() 234 self._caps = set()
225 for l in reversed(lines): 235 for l in reversed(lines):
226 if l.startswith("capabilities:"): 236 if l.startswith("capabilities:"):
227 self._caps.update(l[:-1].split(":")[1].split()) 237 self._caps.update(l[:-1].split(":")[1].split())