Skip to content

Commit

Permalink
Merge 7db1033 into b798551
Browse files Browse the repository at this point in the history
  • Loading branch information
nmichaud committed Sep 21, 2020
2 parents b798551 + 7db1033 commit dde5c27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,18 @@ async def handler(request):
await client_ws.send_message('Hello from client!')


async def test_server_sends_after_close(nursery):
async def handler(request):
server_ws = await request.accept()
with pytest.raises(ConnectionClosed):
await server_ws.send_message("Hello from server")
server = await nursery.start(serve_websocket, handler, HOST, 0, None)
stream = await trio.open_tcp_stream(HOST, server.port)
client_ws = await wrap_client_stream(nursery, stream, HOST, RESOURCE)
async with client_ws:
await stream.aclose()


async def test_server_does_not_close_handshake(nursery):
async def handler(stream):
request = await wrap_server_stream(nursery, stream)
Expand Down
2 changes: 1 addition & 1 deletion trio_websocket/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ async def _handle_message_event(self, event):
self._message_parts = []
try:
await self._send_channel.send(msg)
except trio.BrokenResourceError:
except (trio.ClosedResourceError, trio.BrokenResourceError):
# The receive channel is closed, probably because somebody
# called ``aclose()``. We don't want to abort the reader task,
# and there's no useful cleanup that we can do here.
Expand Down

0 comments on commit dde5c27

Please sign in to comment.