Skip to content

Commit

Permalink
Remove incorrect assertion.
Browse files Browse the repository at this point in the history
Fix python-websockets#646.

See the ticket for details.
  • Loading branch information
aaugustin committed Jul 31, 2019
1 parent 7e0a651 commit fac562d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Changelog
* Restored the ability to pass a socket with the ``sock`` parameter of
:func:`~server.serve`.

* Removed an incorrect assertion when a connection drops.

8.0.1
.....

Expand Down
5 changes: 2 additions & 3 deletions src/websockets/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ async def recv(self) -> Data:
if self.legacy_recv:
return None # type: ignore
else:
assert self.state in [State.CLOSING, State.CLOSED]
# Wait until the connection is closed to raise
# ConnectionClosed with the correct code and reason.
await self.ensure_open()
Expand Down Expand Up @@ -760,8 +759,8 @@ async def ensure_open(self) -> None:
# Handle cases from most common to least common for performance.
if self.state is State.OPEN:
# If self.transfer_data_task exited without a closing handshake,
# self.close_connection_task may be closing it, going straight
# from OPEN to CLOSED.
# self.close_connection_task may be closing the connection, going
# straight from OPEN to CLOSED.
if self.transfer_data_task.done():
await asyncio.shield(self.close_connection_task)
raise self.connection_closed_exc()
Expand Down

0 comments on commit fac562d

Please sign in to comment.