Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/conduit/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ async def disconnect_all_servers(self) -> None:
for server_id in self.server_manager.get_server_ids():
await self.disconnect_server(server_id)

await self.transport.close()

# ================================
# Initialization
# ================================
Expand Down
2 changes: 2 additions & 0 deletions src/conduit/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ async def disconnect_all_clients(self) -> None:
for client_id in self.client_manager.get_client_ids():
await self.disconnect_client(client_id)

await self.transport.close()

# ================================
# Initialization
# ================================
Expand Down
9 changes: 9 additions & 0 deletions src/conduit/transport/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ async def disconnect_server(self, server_id: str) -> None:
server_id: Server connection ID to disconnect
"""
...

@abstractmethod
async def close(self) -> None:
"""Close the transport and clean up all resources.

Should be called when the transport is no longer needed.
Safe to call multiple times - subsequent calls are no-ops.
"""
...
9 changes: 9 additions & 0 deletions src/conduit/transport/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,12 @@ async def disconnect_client(self, client_id: str) -> None:
client_id: Client connection ID to disconnect
"""
...

@abstractmethod
async def close(self) -> None:
"""Close the transport and clean up all resources.

Should be called when the transport is no longer needed.
Safe to call multiple times - subsequent calls are no-ops.
"""
...
5 changes: 5 additions & 0 deletions src/conduit/transport/stdio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,8 @@ async def _shutdown_server_process(
logger.error(f"Error during shutdown of server '{server_id}': {e}")
finally:
server_process.process = None

async def close(self) -> None:
"""Close the transport and clean up all resources."""
for server_id in list(self._servers):
await self.disconnect_server(server_id)
9 changes: 9 additions & 0 deletions src/conduit/transport/stdio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ async def disconnect_client(self, client_id: str) -> None:
pass

sys.exit(0)

async def close(self) -> None:
"""Close the transport and clean up all resources."""
try:
sys.stdout.close()
except Exception:
pass

sys.exit(0)
Loading