roslib: make xmlrpc server more robust to signals

This commit is contained in:
Ken Conley 2011-01-13 23:07:05 +00:00
parent 1450c4a03a
commit 5c6c008862
1 changed files with 15 additions and 6 deletions

View File

@ -231,9 +231,18 @@ class XmlRpcNode(object):
if self.handler is not None:
self.handler._ready(self.uri)
logger.info("xml rpc node: starting XML-RPC server")
try:
self.server.serve_forever()
except:
# ignore on shutdown
if not self.is_shutdown:
raise
while not self.is_shutdown:
try:
self.server.serve_forever()
except IOError as (errno, errstr):
# check for interrupted call, which can occur if we're
# embedded in a program using signals. All other
# exceptions break _run.
if errno != 4:
self.is_shutdown = True
logger.error("serve forever IOError: %s, %s"%(errno, errstr))
# re-raise
raise