Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling decode() and allocating strings for logging if said log lines will no-op anyways. #93

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading