MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / flush_queue

Method flush_queue

relay/instance_registry.py:150–168  ·  view source on GitHub ↗

Flush all queued commands with an error. Called when instance goes to RELOADING or DISCONNECTED state.

(self, error_code: str, error_message: str)

Source from the content-addressed store, hash-verified

148 return None
149
150 def flush_queue(self, error_code: str, error_message: str) -> None:
151 """
152 Flush all queued commands with an error.
153 Called when instance goes to RELOADING or DISCONNECTED state.
154 """
155 from .protocol import ErrorCode, ErrorMessage
156
157 while self.command_queue:
158 cmd = self.command_queue.popleft()
159 if not cmd.future.done():
160 error_response = ErrorMessage.from_code(
161 cmd.request_id,
162 ErrorCode(error_code) if hasattr(ErrorCode, error_code) else ErrorCode.INTERNAL_ERROR,
163 error_message,
164 ).to_dict()
165 cmd.future.set_result(error_response)
166 logger.debug(f"Flushed queued command {cmd.request_id}: {error_code}")
167
168 logger.info(f"Flushed command queue for {self.instance_id}")
169
170 async def close_connection(self) -> None:
171 """Close the connection to this instance"""

Callers 1

close_connectionMethod · 0.95

Calls 4

from_codeMethod · 0.80
infoMethod · 0.80
ErrorCodeClass · 0.70
to_dictMethod · 0.45

Tested by

no test coverage detected