'HTTPTransport' object has no attribute '__aenter__' #2356
Answered
by
tomchristie
miguelsousa
asked this question in
Potential Issue
-
Getting a traceback when running the snippet below.
import asyncio
import httpx
ENDPOINT = "https://github.com/"
async def async_get_without_retries():
async with httpx.AsyncClient() as client:
r = await client.get(ENDPOINT, timeout=1)
print('without retries status:', r.status_code)
async def async_get_with_retries():
transport = httpx.HTTPTransport(retries=3)
async with httpx.AsyncClient(transport=transport) as client:
r = await client.get(ENDPOINT, timeout=1)
print('with retries status:', r.status_code)
asyncio.run(async_get_without_retries())
asyncio.run(async_get_with_retries()) |
Beta Was this translation helpful? Give feedback.
Answered by
tomchristie
Sep 1, 2022
Replies: 1 comment 1 reply
-
Indeed. You'll want See https://www.python-httpx.org/async/#explicit-transport-instances |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
miguelsousa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Indeed. You'll want
AsyncHTTPTransport
.See https://www.python-httpx.org/async/#explicit-transport-instances