Close the connection to this instance
(self)
| 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""" |
| 172 | # Flush queue before closing |
| 173 | if self.command_queue: |
| 174 | self.flush_queue("INSTANCE_DISCONNECTED", "Instance disconnected") |
| 175 | |
| 176 | if self.writer and not self.writer.is_closing(): |
| 177 | self.writer.close() |
| 178 | try: |
| 179 | await self.writer.wait_closed() |
| 180 | except Exception: |
| 181 | pass |
| 182 | self.writer = None |
| 183 | self.reader = None |
| 184 | self.set_status(InstanceStatus.DISCONNECTED) |
| 185 | |
| 186 | |
| 187 | class InstanceRegistry: |