Skip to content

Commit

Permalink
json.dump() each websocket message once instead of twice (#1597)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert authored Jul 31, 2024
1 parent 6937ccd commit a085c2e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions shiny/session/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,15 +955,17 @@ async def send_custom_message(self, type: str, message: dict[str, object]) -> No
await self._send_message({"custom": {type: message}})

async def _send_message(self, message: dict[str, object]) -> None:
message_str: str = json.dumps(message) + "\n"
message_str = json.dumps(message)
if self._debug:
print(
"SEND: "
+ re.sub("(?m)base64,[a-zA-Z0-9+/=]+", "[base64 data]", message_str),
+ re.sub(
"(?m)base64,[a-zA-Z0-9+/=]+", "[base64 data]", message_str + "\n"
),
end="",
flush=True,
)
await self._conn.send(json.dumps(message))
await self._conn.send(message_str)

def _send_message_sync(self, message: dict[str, object]) -> None:
_utils.run_coro_hybrid(self._send_message(message))
Expand Down

0 comments on commit a085c2e

Please sign in to comment.