Skip to content

Commit

Permalink
Call conn.send_failed if stream.send_all fails
Browse files Browse the repository at this point in the history
with an exception.
  • Loading branch information
GalaxySnail authored and pgjones committed Aug 24, 2022
1 parent be52390 commit df0fc1c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/trio-server.py
Expand Up @@ -131,7 +131,13 @@ async def send(self, event):
# appropriate when 'data' is None.
assert type(event) is not h11.ConnectionClosed
data = self.conn.send(event)
await self.stream.send_all(data)
try:
await self.stream.send_all(data)
except BaseException:
# If send_all raises an exception (especially trio.Cancelled),
# we have no choice but to give it up.
self.conn.send_failed()
raise

async def _read_from_peer(self):
if self.conn.they_are_waiting_for_100_continue:
Expand Down

0 comments on commit df0fc1c

Please sign in to comment.