Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Update handlers.py
Browse files Browse the repository at this point in the history
If message is bytes, we should set binary=True
  • Loading branch information
SolarisYan authored and kevin-bates committed May 8, 2019
1 parent 2d3095a commit 46b3cd2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nb2kg/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def on_message(self, message):
def write_message(self, message, binary=False):
"""Send message back to notebook client. This is called via callback from self.gateway._read_messages."""
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)))
Expand Down

0 comments on commit 46b3cd2

Please sign in to comment.