MCPcopy Create free account
hub / github.com/Sphere-AI-Lab/FormalMATH-Bench / process_responses

Method process_responses

verify_answers.py:74–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

72 return None
73
74 def process_responses(self):
75 while not self.stop_flag:
76 self.cmd_query_condition.wait() # Wait for input
77 self.cmd_query_condition.clear()
78
79 if self.stop_flag: # Terminate session
80 break
81
82 try:
83 self.session.expect('\r\n\r\n', timeout=self.expect_timeout) # Filter out input; pexpect prints the input twice for unknown reasons
84 self.session.expect(['\r\n\r\n', pexpect.EOF], timeout=self.expect_timeout)
85 output = self.session.before.strip()
86 output_dict = json.loads(output)
87 self.response = output_dict
88 self.cmd_response_condition.set()
89
90 except pexpect.TIMEOUT:
91 print("Output timeout")
92 self.cmd_response_condition.set() # Prevent thread deadlock
93 break # Terminate session
94 except pexpect.EOF:
95 print("Session ended unexpectedly.")
96 self.cmd_response_condition.set() # Prevent thread deadlock
97 break
98 except json.JSONDecodeError as e:
99 self.cmd_response_condition.set() # Prevent thread deadlock
100 print(output)
101 break
102
103 except Exception as e:
104 print(f"Error in process_responses: {e}")
105 self.cmd_response_condition.set()
106 break
107
108 def remove_last_comment(self):
109 pattern = r'/--[^/]*?-/(\n*)$'

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected