docs: def _request_callback(self, request_id):
          """Construct a request callback for the given request ID."""
          def callback(future):
              # Remove the future from the client requests map
              self._client_request_futures.pop(request_id, None)
  
              if future.cancelled():
                  future.set_exception(JsonRpcRequestCancelled())
  
              message = {
                  'jsonrpc': JSONRPC_VERSION,
                  'id': request_id,
              }
  
              try:
                  message['result'] = future.result()
              except JsonRpcException as e:
                  log.exception("Failed to handle request %s", request_id)
                  message['error'] = e.to_dict()
              except Exception:  # pylint: disable=broad-except
                  log.exception("Failed to handle request %s", request_id)
                  message['error'] = JsonRpcInternalError.of(sys.exc_info()).to_dict()
  
              self._consumer(message)
  
          return callback