Title: Cleanup: WebhookSender.__aenter__ eagerly constructs unused httpx.AsyncClient on owned-client path · Issue #300 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: Cleanup: WebhookSender.__aenter__ eagerly constructs unused httpx.AsyncClient on owned-client path · Issue #300 · adcontextprotocol/adcp-client-python
X Title: Cleanup: WebhookSender.__aenter__ eagerly constructs unused httpx.AsyncClient on owned-client path · Issue #300 · adcontextprotocol/adcp-client-python
Description: Summary WebhookSender.__aenter__ calls _get_client() which constructs self._client = httpx.AsyncClient(timeout=...) even when self._owns_client=True. The owned-client path in _send_bytes ignores self._client entirely — it builds a fresh ...
Open Graph Description: Summary WebhookSender.__aenter__ calls _get_client() which constructs self._client = httpx.AsyncClient(timeout=...) even when self._owns_client=True. The owned-client path in _send_bytes ignores se...
X Description: Summary WebhookSender.__aenter__ calls _get_client() which constructs self._client = httpx.AsyncClient(timeout=...) even when self._owns_client=True. The owned-client path in _send_bytes ignores se...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/300
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cleanup: WebhookSender.__aenter__ eagerly constructs unused httpx.AsyncClient on owned-client path","articleBody":"## Summary\n\n`WebhookSender.__aenter__` calls `_get_client()` which constructs `self._client = httpx.AsyncClient(timeout=...)` even when `self._owns_client=True`. The owned-client path in `_send_bytes` ignores `self._client` entirely — it builds a fresh transport-pinned client per request. The eagerly-constructed `self._client` then sits idle until `__aexit__ → aclose()` closes it.\n\n## Cost\n\nPer `async with sender:` block: one unused `httpx.AsyncClient` allocation (a few hundred bytes + an `httpcore.AsyncConnectionPool` instance). No socket opened (httpx is lazy on first request), so no resource leak.\n\n**Not a correctness bug** — flagged as cosmetic by python-expert in PR #297 review.\n\n## Proposed fix\n\nSkip `await self._get_client()` in `__aenter__` when `self._owns_client=True`:\n\n```python\nasync def __aenter__(self) -> WebhookSender:\n if not self._owns_client:\n await self._get_client() # operator-supplied path still expects this\n return self\n```\n\n`aclose()` already guards on `self._client is not None` so the no-op case works.\n\n## References\n\n- Surfaced by python-expert review on PR #297 (deferred)\n- Code: `src/adcp/webhook_sender.py:262-285` (`__aenter__` + `_get_client`)","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-04-29T17:24:12Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/300"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d7d2e2c7-6e65-3446-8c92-3aaf6d30523c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E27E:6DC60:DE4E0:116D92:6B00F721 |
| html-safe-nonce | 263c262d0471126cf1bbe8682d385623aea16aa9d6ad8ad1abce854fe220111a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjdFOjZEQzYwOkRFNEUwOjExNkQ5Mjo2QjAwRjcyMSIsInZpc2l0b3JfaWQiOiI2Njc0ODUzMzQ0MTY4NzAzNzc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f781d13de772f6a9e2fb59412092c49e8c19b9484b4b174a41b6eb3656085a96 |
| hovercard-subject-tag | issue:4352420810 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/300/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cde6537c9a5d7b5ccf2a68e4a0296673e761b302de1f8eda72f4c56bfb8915cc/adcontextprotocol/adcp-client-python/issues/300 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cde6537c9a5d7b5ccf2a68e4a0296673e761b302de1f8eda72f4c56bfb8915cc/adcontextprotocol/adcp-client-python/issues/300 |
| og:image:alt | Summary WebhookSender.__aenter__ calls _get_client() which constructs self._client = httpx.AsyncClient(timeout=...) even when self._owns_client=True. The owned-client path in _send_bytes ignores se... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width