Skip to content

Commit

Permalink
Merge pull request #93 from judilsteve/fix_debug
Browse files Browse the repository at this point in the history
Avoid calling `decode()` and allocating strings for logging if said log lines will no-op anyways.
  • Loading branch information
sysid authored Apr 4, 2024
2 parents 54d6442 + 2362885 commit ab6f3ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sse_starlette/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ async def stream_response(self, send: Send) -> None:
)
async for data in self.body_iterator:
chunk = ensure_bytes(data, self.sep)
_log.debug(f"chunk: {chunk.decode()}")
_log.debug("chunk: %s", chunk)
with anyio.move_on_after(self.send_timeout) as timeout:
await send(
{"type": "http.response.body", "body": chunk, "more_body": True}
Expand Down Expand Up @@ -322,7 +322,7 @@ async def _ping(self, send: Send) -> None:
if self.ping_message_factory is None
else ensure_bytes(self.ping_message_factory(), self.sep)
)
_log.debug(f"ping: {ping.decode()}")
_log.debug("ping: %s", ping)
async with self._send_lock:
if self.active:
await send(
Expand Down

0 comments on commit ab6f3ef

Please sign in to comment.