From 914a3f0708b134ea90159ee9123dd4454516c48d Mon Sep 17 00:00:00 2001 From: Solaris Date: Sat, 20 Apr 2019 10:40:49 +0800 Subject: [PATCH] Update handlers.py If message is bytes, we should set binary=True --- notebook/gateway/handlers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notebook/gateway/handlers.py b/notebook/gateway/handlers.py index 0fbbfb18b9..06d6cc8fef 100644 --- a/notebook/gateway/handlers.py +++ b/notebook/gateway/handlers.py @@ -80,6 +80,8 @@ def write_message(self, message, binary=False): """Send message back to notebook client. This is called via callback from self.gateway._read_messages.""" self.log.debug("Receiving message from gateway: {}".format(message)) if self.ws_connection: # prevent WebSocketClosedError + if isinstance(message, bytes): + binary = True super(WebSocketChannelsHandler, self).write_message(message, binary=binary) elif self.log.isEnabledFor(logging.DEBUG): msg_summary = WebSocketChannelsHandler._get_message_summary(json_decode(utf8(message)))