def request(method, *args)
      main_thread_only do
        @request_id += 1
        blocking = Fiber.current == @main_fiber

        log(:debug) do
          {
            method_name: method,
            request_id: @request_id,
            blocking: blocking,
            arguments: args
          }
        end

        @event_loop.request(@request_id, method, *args)
        response = blocking ? blocking_response : yielding_response

        raise(Exited) if response.nil?
        raise(response.error) if response.error
        response.value
      end
    end
def request(method, *args)
      main_thread_only do
        @request_id += 1
        blocking = Fiber.current == @main_fiber

        log(:debug) do
          {
            method_name: method,
            request_id: @request_id,
            blocking: blocking,
            arguments: args
          }
        end

        @event_loop.request(@request_id, method, *args)
        response = blocking ? blocking_response : yielding_response

        raise(Exited) if response.nil?
        raise(response.error) if response.error
        response.value
      end
    end
Make an RPC request and return its response.

 If this method is called inside a callback, we are already inside a
 +Fiber+ handler. In that case, we write to the stream and yield the
 +Fiber+. Once the response is received, resume the +Fiber+ and
 return the result.

 If this method is called outside a callback, write to the stream and
 run the event loop until a response is received. Messages received
 in the meantime are enqueued to be handled later.