]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Fix websocket client already closed raise error does not match
authorqcha0 <agnewee@gmail.com>
Fri, 3 Sep 2021 10:19:44 +0000 (18:19 +0800)
committerqcha0 <agnewee@gmail.com>
Fri, 3 Sep 2021 10:19:44 +0000 (18:19 +0800)
As doc says "If the stream is closed, raises WebSocketClosedError"

tornado/websocket.py

index c88cc2074d8d2a50427c9490c8f802c1a03802f0..f2711c94fb911b2b94ce75497e6c94b88b18495c 100644 (file)
@@ -1501,6 +1501,8 @@ class WebSocketClientConnection(simple_httpclient._HTTPConnection):
            Exception raised on a closed stream changed from `.StreamClosedError`
            to `WebSocketClosedError`.
         """
+        if self.protocol is None:
+            raise WebSocketClosedError("Client connection has been closed")
         return self.protocol.write_message(message, binary=binary)
 
     def read_message(