commit 96d9ae5b4d1654957f155e95c5bf1ad4ac65c734 parent a893507946bf1451ddd4235bd60966e87556c6e8 Author: Sheng <webmaster0115@gmail.com> Date: Sat, 26 May 2018 16:23:55 +0800 Use JSONDecodeError Diffstat:
M | webssh/handler.py | | | 9 | ++++++--- |
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/webssh/handler.py b/webssh/handler.py @@ -18,6 +18,11 @@ try: except ImportError: from tornado.concurrent import Future +try: + from json.decoder import JSONDecodeError +except ImportError: + JSONDecodeError = ValueError + DELAY = 3 @@ -204,9 +209,7 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler): worker = self.worker_ref() try: msg = json.loads(message) - except ValueError: # py2 - return - except json.decoder.JSONDecodeError: # py3 + except JSONDecodeError: return if not isinstance(msg, dict):