##// END OF EJS Templates
commandserver: separate initialization and cleanup of forked process...
Yuya Nishihara -
r29586:42cdba9c default
parent child Browse files
Show More
@@ -342,7 +342,7 b' class pipeservice(object):'
342 sv.cleanup()
342 sv.cleanup()
343 _restoreio(ui, fin, fout)
343 _restoreio(ui, fin, fout)
344
344
345 def _serverequest(ui, repo, conn, createcmdserver):
345 def _initworkerprocess():
346 # use a different process group from the master process, making this
346 # use a different process group from the master process, making this
347 # process pass kernel "is_current_pgrp_orphaned" check so signals like
347 # process pass kernel "is_current_pgrp_orphaned" check so signals like
348 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
348 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
@@ -351,6 +351,7 b' def _serverequest(ui, repo, conn, create'
351 # same state inherited from parent.
351 # same state inherited from parent.
352 random.seed()
352 random.seed()
353
353
354 def _serverequest(ui, repo, conn, createcmdserver):
354 fin = conn.makefile('rb')
355 fin = conn.makefile('rb')
355 fout = conn.makefile('wb')
356 fout = conn.makefile('wb')
356 sv = None
357 sv = None
@@ -385,8 +386,6 b' def _serverequest(ui, repo, conn, create'
385 except IOError as inst:
386 except IOError as inst:
386 if inst.errno != errno.EPIPE:
387 if inst.errno != errno.EPIPE:
387 raise
388 raise
388 # trigger __del__ since ForkingMixIn uses os._exit
389 gc.collect()
390
389
391 class unixservicehandler(object):
390 class unixservicehandler(object):
392 """Set of pluggable operations for unix-mode services
391 """Set of pluggable operations for unix-mode services
@@ -517,8 +516,12 b' class unixforkingservice(object):'
517
516
518 def _serveworker(self, conn):
517 def _serveworker(self, conn):
519 signal.signal(signal.SIGCHLD, self._oldsigchldhandler)
518 signal.signal(signal.SIGCHLD, self._oldsigchldhandler)
519 _initworkerprocess()
520 h = self._servicehandler
520 h = self._servicehandler
521 _serverequest(self.ui, self.repo, conn, h.createcmdserver)
521 try:
522 _serverequest(self.ui, self.repo, conn, h.createcmdserver)
523 finally:
524 gc.collect() # trigger __del__ since worker process uses os._exit
522
525
523 _servicemap = {
526 _servicemap = {
524 'pipe': pipeservice,
527 'pipe': pipeservice,
General Comments 0
You need to be logged in to leave comments. Login now