##// END OF EJS Templates
commandserver: unindent superfluous "if True" blocks
Yuya Nishihara -
r29585:6ed452d0 default
parent child Browse files
Show More
@@ -581,13 +581,12 b' class chgunixservicehandler(object):'
581 581 pass
582 582
583 583 def shouldexit(self):
584 if True: # TODO: unindent
585 if not self.issocketowner():
586 _log('%s is not owned, exiting.\n' % self.address)
587 return True
588 if time.time() - self.lastactive > self.idletimeout:
589 _log('being idle too long. exiting.\n')
590 return True
584 if not self.issocketowner():
585 _log('%s is not owned, exiting.\n' % self.address)
586 return True
587 if time.time() - self.lastactive > self.idletimeout:
588 _log('being idle too long. exiting.\n')
589 return True
591 590 return False
592 591
593 592 def newconnection(self):
@@ -343,51 +343,50 b' class pipeservice(object):'
343 343 _restoreio(ui, fin, fout)
344 344
345 345 def _serverequest(ui, repo, conn, createcmdserver):
346 if True: # TODO: unindent
347 # use a different process group from the master process, making this
348 # process pass kernel "is_current_pgrp_orphaned" check so signals like
349 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
350 os.setpgid(0, 0)
351 # change random state otherwise forked request handlers would have a
352 # same state inherited from parent.
353 random.seed()
346 # use a different process group from the master process, making this
347 # process pass kernel "is_current_pgrp_orphaned" check so signals like
348 # SIGTSTP, SIGTTIN, SIGTTOU are not ignored.
349 os.setpgid(0, 0)
350 # change random state otherwise forked request handlers would have a
351 # same state inherited from parent.
352 random.seed()
354 353
355 fin = conn.makefile('rb')
356 fout = conn.makefile('wb')
357 sv = None
354 fin = conn.makefile('rb')
355 fout = conn.makefile('wb')
356 sv = None
357 try:
358 sv = createcmdserver(repo, conn, fin, fout)
358 359 try:
359 sv = createcmdserver(repo, conn, fin, fout)
360 try:
361 sv.serve()
362 # handle exceptions that may be raised by command server. most of
363 # known exceptions are caught by dispatch.
364 except error.Abort as inst:
365 ui.warn(_('abort: %s\n') % inst)
366 except IOError as inst:
367 if inst.errno != errno.EPIPE:
368 raise
369 except KeyboardInterrupt:
370 pass
371 finally:
372 sv.cleanup()
373 except: # re-raises
374 # also write traceback to error channel. otherwise client cannot
375 # see it because it is written to server's stderr by default.
376 if sv:
377 cerr = sv.cerr
378 else:
379 cerr = channeledoutput(fout, 'e')
380 traceback.print_exc(file=cerr)
381 raise
360 sv.serve()
361 # handle exceptions that may be raised by command server. most of
362 # known exceptions are caught by dispatch.
363 except error.Abort as inst:
364 ui.warn(_('abort: %s\n') % inst)
365 except IOError as inst:
366 if inst.errno != errno.EPIPE:
367 raise
368 except KeyboardInterrupt:
369 pass
382 370 finally:
383 fin.close()
384 try:
385 fout.close() # implicit flush() may cause another EPIPE
386 except IOError as inst:
387 if inst.errno != errno.EPIPE:
388 raise
389 # trigger __del__ since ForkingMixIn uses os._exit
390 gc.collect()
371 sv.cleanup()
372 except: # re-raises
373 # also write traceback to error channel. otherwise client cannot
374 # see it because it is written to server's stderr by default.
375 if sv:
376 cerr = sv.cerr
377 else:
378 cerr = channeledoutput(fout, 'e')
379 traceback.print_exc(file=cerr)
380 raise
381 finally:
382 fin.close()
383 try:
384 fout.close() # implicit flush() may cause another EPIPE
385 except IOError as inst:
386 if inst.errno != errno.EPIPE:
387 raise
388 # trigger __del__ since ForkingMixIn uses os._exit
389 gc.collect()
391 390
392 391 class unixservicehandler(object):
393 392 """Set of pluggable operations for unix-mode services
General Comments 0
You need to be logged in to leave comments. Login now