def safe_dispatch(self, name, args):
    """restrict calls to selected methods, and trap all exceptions to
    keep server alive!"""
    import datetime
    if name in self.xmlrpc_methods:
        # Make sure this method is explicitly allowed.
        try: # TRAP ALL ERRORS TO PREVENT OUR SERVER FROM DYING
            print >>sys.stderr, 'XMLRPC:', name, args, \
                  datetime.datetime.now().isoformat(' ') # LOG THE REQUEST
            if self.xmlrpc_methods[name]: # use this as an alias for method
                m = getattr(self, self.xmlrpc_methods[name])
            else: # use method name as usual
                m = getattr(self, name) # GET THE BOUND METHOD
            val = m(*args) # CALL THE METHOD
            sys.stderr.flush() # FLUSH ANY OUTPUT TO OUR LOG
            return val # HAND BACK ITS RETURN VALUE
        except __HOLE__:
            raise  # WE REALLY DO WANT TO EXIT.
        except: # METHOD RAISED AN EXCEPTION, SO PRINT TRACEBACK TO STDERR
            traceback.print_exc(self.max_tb, sys.stderr)
    else:
        print >>sys.stderr, "safe_dispatch: blocked unregistered method %s" \
                % name
    return False # THIS RETURN VALUE IS CONFORMABLE BY XMLRPC...
dataset/ETHPy150Open cjlee112/pygr/pygr/coordinator.py/safe_dispatch