Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commandserver.py @ 29512:538d0003c9e0
commandserver: promote .cleanup() hook from chgserver
This allows us to unify _requesthandler.handle().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 May 2016 15:18:23 +0900 |
parents | 540c01a18bb7 |
children | e5b4d79a9140 |
line wrap: on
line diff
--- a/mercurial/commandserver.py Sat May 21 15:12:19 2016 +0900 +++ b/mercurial/commandserver.py Sat May 21 15:18:23 2016 +0900 @@ -179,6 +179,10 @@ self.client = fin + def cleanup(self): + """release and restore resources taken during server session""" + pass + def _read(self, size): if not size: return '' @@ -329,6 +333,7 @@ sv = server(ui, self.repo, fin, fout) return sv.serve() finally: + sv.cleanup() _restoreio(ui, fin, fout) class _requesthandler(socketserver.StreamRequestHandler): @@ -348,6 +353,8 @@ raise except KeyboardInterrupt: pass + finally: + sv.cleanup() except: # re-raises # also write traceback to error channel. otherwise client cannot # see it because it is written to server's stderr by default.