Skip to content

Commit

Permalink
[PR #9031/9f0ae074 backport][3.10] Avoid tracing overhead in http_wri…
Browse files Browse the repository at this point in the history
…ter when there are no traces (#9045)

Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
patchback[bot] and bdraco committed Sep 6, 2024
1 parent f5bf86a commit 9c34a8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/9031.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tracing overhead is avoided in the http writer when there are no active traces -- by user:`bdraco`.
12 changes: 8 additions & 4 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,15 @@ async def send(self, conn: "Connection") -> "ClientResponse":
writer = StreamWriter(
protocol,
self.loop,
on_chunk_sent=functools.partial(
self._on_chunk_request_sent, self.method, self.url
on_chunk_sent=(
functools.partial(self._on_chunk_request_sent, self.method, self.url)
if self._traces
else None
),
on_headers_sent=functools.partial(
self._on_headers_request_sent, self.method, self.url
on_headers_sent=(
functools.partial(self._on_headers_request_sent, self.method, self.url)
if self._traces
else None
),
)

Expand Down

0 comments on commit 9c34a8c

Please sign in to comment.