def initialize(self, inputs: UnityInputProto) -> UnityOutputProto:
     self.poll_for_timeout()
     aca_param = self.unity_to_external.parent_conn.recv().unity_output
     message = UnityMessageProto()
     message.header.status = 200
     message.unity_input.CopyFrom(inputs)
     self.unity_to_external.parent_conn.send(message)
     self.unity_to_external.parent_conn.recv()
     return aca_param
 def exchange(self, inputs: UnityInputProto) -> Optional[UnityOutputProto]:
     message = UnityMessageProto()
     message.header.status = 200
     message.unity_input.CopyFrom(inputs)
     self.unity_to_external.parent_conn.send(message)
     self.poll_for_timeout()
     output = self.unity_to_external.parent_conn.recv()
     if output.header.status != 200:
         return None
     return output.unity_output
 def close(self):
     """
     Sends a shutdown signal to the unity environment, and closes the grpc connection.
     """
     if self.is_open:
         message_input = UnityMessageProto()
         message_input.header.status = 400
         self.unity_to_external.parent_conn.send(message_input)
         self.unity_to_external.parent_conn.close()
         self.server.stop(False)
         self.is_open = False