Skip to content

fix(adcp): skip eager httpx.AsyncClient alloc in WebhookSender.__aenter__ on owned-client path#301

Merged
bokelley merged 1 commit intomainfrom
claude/issue-300-webhook-sender-aenter-lazy-alloc
Apr 29, 2026
Merged

fix(adcp): skip eager httpx.AsyncClient alloc in WebhookSender.__aenter__ on owned-client path#301
bokelley merged 1 commit intomainfrom
claude/issue-300-webhook-sender-aenter-lazy-alloc

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Closes #300

When WebhookSender owns its client (_owns_client=True, i.e. no caller-supplied client=), __aenter__ was unconditionally calling _get_client(), which allocated an httpx.AsyncClient that sat idle until __aexit__. On the owned-client path, _send_bytes calls _get_client() lazily at first use anyway, so the eager allocation in __aenter__ was wasted. The fix skips it; the operator-supplied-client branch (_owns_client=False) still calls _get_client() for symmetry, though that call is a no-op since self._client is already set.

What was tested

  • pytest tests/ -k "webhook_sender or webhook" — 182 passed, 0 failed
  • ruff check src/ — clean
  • mypy src/adcp/webhook_sender.py — no new errors (pre-existing errors are in unrelated files)

Pre-PR review

  • code-reviewer: approved — fix correct and non-breaking; nit: _get_client() call on _owns_client=False branch is a harmless no-op but could be removed for clarity.
  • dx-expert: approved — both async with WebhookSender(...) paths (owned and operator-supplied) preserve their existing contract; no docstring update needed.

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num>
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}


Generated by Claude Code

…er__ on owned-client path

When WebhookSender owns the client (_owns_client=True), __aenter__ was
unconditionally calling _get_client(), which allocates an AsyncClient
that goes unused until __aexit__ on the owned-client path. The client
is created lazily on the first _send_bytes call instead.

Closes #300

https://claude.ai/code/${CLAUDE_CODE_REMOTE_SESSION_ID}
@bokelley bokelley marked this pull request as ready for review April 29, 2026 23:23
@bokelley bokelley merged commit 4bd45d1 into main Apr 29, 2026
11 checks passed
@bokelley bokelley deleted the claude/issue-300-webhook-sender-aenter-lazy-alloc branch April 29, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup: WebhookSender.__aenter__ eagerly constructs unused httpx.AsyncClient on owned-client path

2 participants