code: def handle_request(self):
          
          request = self.read_json()
          if 'method' not in request:
              raise ValueError("Received a bad request: {0}"
                               .format(request))
          method_name = request['method']
          request_id = request.get('id', None)
          params = request.get('params') or []
          try:
              method = getattr(self, "rpc_" + method_name, None)
              if method is not None:
                  result = method(*params)
              else:
                  result = self.handle(method_name, params)
              if request_id is not None:
                  self.write_json(result=result,
                                  id=request_id)
          except Fault as fault:
              error = {"message": fault.message,
                       "code": fault.code}
              if fault.data is not None:
                  error["data"] = fault.data
              self.write_json(error=error, id=request_id)
          except Exception as e:
              error = {"message": str(e),
                       "code": 500,
                       "data": {"traceback": traceback.format_exc()}}
              self.write_json(error=error, id=request_id)
docs: Handle a single JSON-RPC request.
  
          Read a request, call the appropriate handler method, and
          return the encoded result. Errors in the handler method are
          caught and encoded as error objects. Errors in the decoding
          phase are not caught, as we can not respond with an error
          response to them.