Flush all queued commands with an error. Called when instance goes to RELOADING or DISCONNECTED state.
(self, error_code: str, error_message: str)
| 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""" |
no test coverage detected