Skip to content

Commit df0fc1c

Browse files
GalaxySnailpgjones
authored andcommitted
Call conn.send_failed if stream.send_all fails
with an exception.
1 parent be52390 commit df0fc1c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/trio-server.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ async def send(self, event):
131131
# appropriate when 'data' is None.
132132
assert type(event) is not h11.ConnectionClosed
133133
data = self.conn.send(event)
134-
await self.stream.send_all(data)
134+
try:
135+
await self.stream.send_all(data)
136+
except BaseException:
137+
# If send_all raises an exception (especially trio.Cancelled),
138+
# we have no choice but to give it up.
139+
self.conn.send_failed()
140+
raise
135141

136142
async def _read_from_peer(self):
137143
if self.conn.they_are_waiting_for_100_continue:

0 commit comments

Comments
 (0)