The Fix
Upgrade to version 0.13.0 or later.
Based on closed encode/httpx issue #179 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -105,3 +105,38 @@ trio.run(main)
!!! important
`trio` must be installed to import and use the `TrioBackend`.
+
+## FAQ
+
import httpx
...
class SomeClass(object):
def get_some_url(self):
r = httpx.get('some url')
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 0.13.0 or later.\nWhen NOT to use: Avoid using sync methods in an async environment to prevent blocking the event loop.\n\n
Why This Fix Works in Production
- Trigger: self.client = httpx.Client(backend=kwargs.get('runloop'))
- Mechanism: The sync methods in httpx use async calls, causing conflicts with existing event loops
- Why the fix works: Document when to use AsyncClient to avoid blocking-style network calls in async environments. (first fixed release: 0.13.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.6 in real deployments (not just unit tests).
- The sync methods in httpx use async calls, causing conflicts with existing event loops
- Surfaces as: self.client = httpx.Client(backend=kwargs.get('runloop'))
Proof / Evidence
- GitHub issue: #179
- Fix PR: https://github.com/encode/httpx/pull/534
- First fixed release: 0.13.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.67
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“> FWIW; I tried the following in a vein hope that it would do what I wanted: > > > > But alas, no success..…”
“Yeah, I figured that after I got the exception. I figured it would handle a standard runloop.”
“There is no API to provide the event loop yourself, however there is a loop property in the AsyncioConcurrencyBackend that checks an existing private _loop…”
“FWIW; I tried the following in a vein hope that it would do what I wanted: But alas, no success.. this the end of the…”
Failure Signature (Search String)
- self.client = httpx.Client(backend=kwargs.get('runloop'))
Error Message
Stack trace
Error Message
-------------
self.client = httpx.Client(backend=kwargs.get('runloop'))
File "/usr/local/lib/python3.6/site-packages/httpx/client.py", line 85, in __init__
backend=backend,
File "/usr/local/lib/python3.6/site-packages/httpx/dispatch/connection_pool.py", line 97, in __init__
self.max_connections = self.backend.get_semaphore(pool_limits)
AttributeError: 'Loop' object has no attribute 'get_semaphore'
Minimal Reproduction
import httpx
...
class SomeClass(object):
def get_some_url(self):
r = httpx.get('some url')
Environment
- Python: 3.6
What Broke
Using sync methods in an async context leads to exceptions about running multiple event loops.
Why It Broke
The sync methods in httpx use async calls, causing conflicts with existing event loops
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.13.0 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/encode/httpx/pull/534
First fixed release: 0.13.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Avoid using sync methods in an async environment to prevent blocking the event loop.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
- Add a stress test that runs high-concurrency workloads and fails on thread dumps / blocked locks.
- Enable watchdog dumps in prod (faulthandler, thread dump endpoint) to capture deadlocks quickly.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.13.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.