René's URL Explorer Experiment


Title: Add support for httpx and async transport · Issue #15134 · googleapis/google-cloud-python · GitHub

Open Graph Title: Add support for httpx and async transport · Issue #15134 · googleapis/google-cloud-python

X Title: Add support for httpx and async transport · Issue #15134 · googleapis/google-cloud-python

Description: Add support for httpx for async transport. An exemplar PR to support this is available (it is currently closed to enable migration to the Python mono-repo). Both aiohttp and httpx are powerful libraries for making asynchronous HTTP reque...

Open Graph Description: Add support for httpx for async transport. An exemplar PR to support this is available (it is currently closed to enable migration to the Python mono-repo). Both aiohttp and httpx are powerful libr...

X Description: Add support for httpx for async transport. An exemplar PR to support this is available (it is currently closed to enable migration to the Python mono-repo). Both aiohttp and httpx are powerful libr...

Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/15134

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for httpx and async transport","articleBody":"Add support for httpx for async transport. [An exemplar PR](https://github.com/googleapis/google-auth-library-python/pull/1908) to support this is available (it is currently closed to enable migration to the [Python mono-repo](https://github.com/googleapis/google-cloud-python)).\n\nBoth `aiohttp` and `httpx` are powerful libraries for making asynchronous HTTP requests in Python, but they serve slightly different purposes and have different design philosophies.\n\nHere is a breakdown of their differences, pros, cons, and when to use each, as provided by Gemini AI.\n\n---\n\n### 1. High-Level Overview\n\n*   **aiohttp:** The \"venerable\" choice. It has been the industry standard for asynchronous HTTP in Python for years. It is a full-featured networking library that provides both a **Client** and a **Server** framework.\n*   **httpx:** The \"modern\" choice. It was designed to be the spiritual successor to the famous `requests` library, but built for the modern `asyncio` era. Its biggest selling point is that it supports both **Synchronous** and **Asynchronous** APIs and has built-in support for **HTTP/2**.\n\n---\n\n### 2. Key Differences\n\n| Feature | aiohttp | httpx |\n| :--- | :--- | :--- |\n| **Sync Support** | No (Async only) | Yes (Sync and Async) |\n| **API Style** | Unique, explicit (requires `ClientSession`) | Very similar to `requests` |\n| **HTTP/2 Support** | No (supports HTTP/1.1 only) | Yes (Optional) |\n| **Web Server** | Yes (Built-in) | No (Client only) |\n| **Type Hinting** | Good | Excellent (Fully type-annotated) |\n| **Cookie/Session** | Strictly via `ClientSession` | Flexible (Top-level or Client) |\n\n---\n\n### 3. aiohttp\n\n#### Pros:\n*   **Performance:** Generally considered slightly faster and more efficient in high-concurrency benchmarks because it is highly optimized for `asyncio`.\n*   **Maturity:** It is battle-tested and has been used in production by major companies for nearly a decade.\n*   **All-in-one:** If you are building a web server and also need to make outgoing requests, you only need one library.\n*   **Control:** Offers lower-level control over connections and TCP parameters.\n\n#### Cons:\n*   **Async-Only:** You cannot use it in a synchronous script. This makes it difficult to share code between sync and async parts of a codebase.\n*   **Boilerplate:** It is more verbose. You *must* use a `ClientSession` context manager for almost everything.\n*   **No HTTP/2:** It currently does not support HTTP/2 for its client.\n\n---\n\n### 4. httpx\n\n#### Pros:\n*   **The \"Requests\" Feel:** If you know how to use `requests`, you know how to use `httpx`. The transition is almost seamless.\n*   **Sync \u0026 Async:** You can use `httpx.get()` for a quick script and `await client.get()` for an async app. This allows library authors to support both paradigms easily.\n*   **HTTP/2 Support:** This is a major advantage for modern web scraping and communicating with APIs that prioritize HTTP/2.\n*   **Strictness:** It has better defaults for things like timeouts (it enforces them by default, whereas `aiohttp` often doesn't).\n*   **WSGI/ASGI Support:** You can call your FastAPI or Flask app directly through `httpx` for testing without needing a running server.\n\n#### Cons:\n*   **Performance:** In some raw benchmarks, it is slightly slower than `aiohttp` (though this is rarely the bottleneck in real-world IO-bound applications).\n*   **Client Only:** It does not include a web server framework.\n\n---\n\n### 5. Code Comparison\n\n**aiohttp (Async only):**\n```python\nimport aiohttp\nimport asyncio\n\nasync def main():\n    async with aiohttp.ClientSession() as session:\n        async with session.get('https://example.com') as response:\n            print(response.status)\n            print(await response.text())\n\nasyncio.run(main())\n```\n\n**httpx (Async):**\n```python\nimport httpx\nimport asyncio\n\nasync def main():\n    async with httpx.AsyncClient() as client:\n        response = await client.get('https://example.com')\n        print(response.status_code)\n        print(response.text)\n\nasyncio.run(main())\n```\n\n---\n\n### 6. When to use which?\n\n#### Use **httpx** if:\n1.  **You want the best developer experience:** The API is cleaner and more intuitive.\n2.  **You need HTTP/2:** This is a non-negotiable requirement for some modern APIs.\n3.  **You are migrating from `requests`:** It will be much easier to port your code.\n4.  **You need both Sync and Async:** If you are writing a library or a CLI tool that needs to support both modes.\n5.  **You are using FastAPI:** `httpx` is the standard recommendation for testing and making external calls within FastAPI.\n\n#### Use **aiohttp** if:\n1.  **You are building a high-performance web server:** Using `aiohttp` as both the server and client keeps your stack unified.\n2.  **Raw speed is the googleapis/google-auth-library-python#1 priority:** If you are making millions of requests and every millisecond of overhead matters.\n3.  **Legacy codebases:** If you are working on an existing project that already uses `aiohttp`, there is rarely a compelling reason to switch.\n4.  **Complex TCP/Networking requirements:** If you need deep control over the underlying transport layer.\n\n### Summary\nFor **90% of new projects**, **`httpx`** is the recommended choice because of its flexibility, HTTP/2 support, and modern API. Use **`aiohttp`** only if you need its server-side capabilities or are working in a performance-critical, async-only environment where every drop of optimization counts.","author":{"url":"https://github.com/chalmerlowe","@type":"Person","name":"chalmerlowe"},"datePublished":"2025-12-30T12:40:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/15134/google-cloud-python/issues/15134"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:bf3ad691-70eb-e611-5445-cdf4269b5154
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE8A4:3B806F:10FF888:16EF89D:697328B6
html-safe-nonce82c5e9dc25d325296cd3ea82e4b04cf19fe72390b050a190636b8068d95e9991
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEE0OjNCODA2RjoxMEZGODg4OjE2RUY4OUQ6Njk3MzI4QjYiLCJ2aXNpdG9yX2lkIjoiMjkyNzQwODY1NDE4MzAzMjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4a1c4297410c5c0f2a4f48e0906be621ef37061f6646404c3858235a6b999149
hovercard-subject-tagissue:3805914811
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/15134/issue_layout
twitter:imagehttps://opengraph.githubassets.com/642f0f36a89daba04942f505748e6b19a3c6ef81cc9b34e985ca54ff97eb4fbe/googleapis/google-cloud-python/issues/15134
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/642f0f36a89daba04942f505748e6b19a3c6ef81cc9b34e985ca54ff97eb4fbe/googleapis/google-cloud-python/issues/15134
og:image:altAdd support for httpx for async transport. An exemplar PR to support this is available (it is currently closed to enable migration to the Python mono-repo). Both aiohttp and httpx are powerful libr...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechalmerlowe
hostnamegithub.com
expected-hostnamegithub.com
None44ab3188c1dcfe3be0f9c3feca2e04e14fb79f120939ce2395e4f15ab96ec1d4
turbo-cache-controlno-preview
go-importgithub.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id16316451
octolytics-dimension-repository_nwogoogleapis/google-cloud-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id16316451
octolytics-dimension-repository_network_root_nwogoogleapis/google-cloud-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea5e2b48bd1260476599758f5d253b5d24092ab84
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues/15134#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-cloud-python%2Fissues%2F15134
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fgoogle-cloud-python%2Fissues%2F15134
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fgoogle-cloud-python
Reloadhttps://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues/15134
Reloadhttps://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues/15134
Reloadhttps://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues/15134
googleapis https://patch-diff.githubusercontent.com/googleapis
google-cloud-pythonhttps://patch-diff.githubusercontent.com/googleapis/google-cloud-python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fgoogleapis%2Fgoogle-cloud-python
Fork 1.6k https://patch-diff.githubusercontent.com/login?return_to=%2Fgoogleapis%2Fgoogle-cloud-python
Star 5.2k https://patch-diff.githubusercontent.com/login?return_to=%2Fgoogleapis%2Fgoogle-cloud-python
Code https://patch-diff.githubusercontent.com/googleapis/google-cloud-python
Issues 581 https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues
Pull requests 20 https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/pulls
Discussions https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/discussions
Actions https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/actions
Projects 0 https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/projects
Security 0 https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/security
Insights https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/pulse
Code https://patch-diff.githubusercontent.com/googleapis/google-cloud-python
Issues https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues
Pull requests https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/pulls
Discussions https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/discussions
Actions https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/actions
Projects https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/projects
Security https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/security
Insights https://patch-diff.githubusercontent.com/googleapis/google-cloud-python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/googleapis/google-cloud-python/issues/15134
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/googleapis/google-cloud-python/issues/15134
Add support for httpx and async transporthttps://patch-diff.githubusercontent.com/googleapis/google-cloud-python/issues/15134#top
https://github.com/chalmerlowe
https://github.com/chalmerlowe
chalmerlowehttps://github.com/chalmerlowe
on Dec 30, 2025https://github.com/googleapis/google-cloud-python/issues/15134#issue-3805914811
An exemplar PRhttps://github.com/googleapis/google-auth-library-python/pull/1908
Python mono-repohttps://github.com/googleapis/google-cloud-python
Internal transport discussion google-auth-library-python#1https://github.com/googleapis/google-auth-library-python/issues/1
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.