mirror of
https://github.com/Textualize/textual-web.git
synced 2025-10-17 02:36:40 +03:00
catch send fails
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user