class_docstr: A generic context for sending requests to a java program using protobufs in a subprocess
class_docstr_tok: ["A","generic","context","for","sending","requests","to","a","java","program","using","protobufs","in","a","subprocess"]
code: def process_request(self, request):
      if self.pipe is None:
          raise RuntimeError(
              "Pipe to java process is not open or was closed"
          )
  
      text = request.SerializeToString()
      self.pipe.stdin.write(len(text).to_bytes(4, "big"))
      self.pipe.stdin.write(text)
      self.pipe.stdin.flush()
      response_length = self.pipe.stdout.read(4)
      if len(response_length) < 4:
          raise BrokenPipeError(
              "Could not communicate with java process!"
          )
      response_length = int.from_bytes(response_length, "big")
      response_text = self.pipe.stdout.read(response_length)
      response = self.build_response()
      response.ParseFromString(response_text)
      return response
  
imports: from collections import deque
  import subprocess
  from stanza.models.common.utils import misc_to_space_after
  from stanza.models.constituency.parse_tree import Tree
  from stanza.protobuf import DependencyGraph, FlattenedParseTree
  from stanza.server.client import resolve_classpath
label_desc: Use image node_id 6 for calling the JavaProtobufContext obj's underlying member method code with example usage: obj.process_request(request) and returns: response