##// END OF EJS Templates
sshpeer: extract pipe cleanup logic to own function...
Gregory Szorc -
r35951:805edf16 default
parent child Browse files
Show More
@@ -114,6 +114,23 b' class doublepipe(object):'
114 def flush(self):
114 def flush(self):
115 return self._main.flush()
115 return self._main.flush()
116
116
117 def _cleanuppipes(ui, pipei, pipeo, pipee):
118 """Clean up pipes used by an SSH connection."""
119 if pipeo:
120 pipeo.close()
121 if pipei:
122 pipei.close()
123
124 if pipee:
125 # Try to read from the err descriptor until EOF.
126 try:
127 for l in pipee:
128 ui.status(_('remote: '), l)
129 except (IOError, ValueError):
130 pass
131
132 pipee.close()
133
117 class sshpeer(wireproto.wirepeer):
134 class sshpeer(wireproto.wirepeer):
118 def __init__(self, ui, path, create=False, sshstate=None):
135 def __init__(self, ui, path, create=False, sshstate=None):
119 self._url = path
136 self._url = path
@@ -221,17 +238,7 b' class sshpeer(wireproto.wirepeer):'
221 raise exception
238 raise exception
222
239
223 def _cleanup(self):
240 def _cleanup(self):
224 if self._pipeo is None:
241 _cleanuppipes(self.ui, self._pipei, self._pipeo, self._pipee)
225 return
226 self._pipeo.close()
227 self._pipei.close()
228 try:
229 # read the error descriptor until EOF
230 for l in self._pipee:
231 self.ui.status(_("remote: "), l)
232 except (IOError, ValueError):
233 pass
234 self._pipee.close()
235
242
236 __del__ = _cleanup
243 __del__ = _cleanup
237
244
General Comments 0
You need to be logged in to leave comments. Login now