catch send fails

This commit is contained in:
Will McGugan
2023-09-03 14:14:07 +01:00
parent 4910ca5d49
commit 5e381118aa
2 changed files with 9 additions and 2 deletions

View File

@@ -281,7 +281,10 @@ class AppSession(Session):
True if the data was sent, otherwise False.
"""
stdin = self.stdin
stdin.write(self.encode_packet(b"D", data))
try:
stdin.write(self.encode_packet(b"D", data))
except RuntimeError:
return False
await stdin.drain()
return True
@@ -296,6 +299,9 @@ class AppSession(Session):
"""
stdin = self.stdin
data_bytes = json.dumps(data).encode("utf-8")
stdin.write(self.encode_packet(b"M", data_bytes))
try:
stdin.write(self.encode_packet(b"M", data_bytes))
except RuntimeError:
return False
await stdin.drain()
return True

View File

@@ -361,6 +361,7 @@ class GanglionClient(Handlers):
connector = _ClientConnector(
self, cast(SessionID, packet.session_id), cast(RouteKey, route_key)
)
await session_process.start(connector)
async def on_session_close(self, packet: SessionClose) -> None: