comparison hglib/client.py @ 168:d71bd813c9d7

client: use subprocess.communicate() to shut down server process This allows us to get stderr output with no deadlock risk. Also, it should fix possible deadlock issue at server.wait(). https://docs.python.org/2.7/library/subprocess.html#subprocess.Popen.wait
author Yuya Nishihara <yuya@tcha.org>
date Mon, 07 Sep 2015 22:32:12 +0900
parents f22f3ff3cfae
children e6589149b2c8
comparison
equal deleted inserted replaced
167:f22f3ff3cfae 168:d71bd813c9d7
198 returns the exit code. 198 returns the exit code.
199 199
200 Attempting to call any function afterwards that needs to 200 Attempting to call any function afterwards that needs to
201 communicate with the server will raise a ValueError. 201 communicate with the server will raise a ValueError.
202 """ 202 """
203 return self._close() 203 return self._close()[0]
204 204
205 def _close(self): 205 def _close(self):
206 self.server.stdin.close() 206 _sout, serr = self.server.communicate()
207 self.server.wait()
208 ret = self.server.returncode 207 ret = self.server.returncode
209 self.server = None 208 self.server = None
210 return ret 209 return ret, serr
211 210
212 def add(self, files=[], dryrun=False, subrepos=False, include=None, 211 def add(self, files=[], dryrun=False, subrepos=False, include=None,
213 exclude=None): 212 exclude=None):
214 """ 213 """
215 Add the specified files on the next commit. 214 Add the specified files on the next commit.