-
Hi, guys! I want to use httpx as a base for my client to external API. I want to create wrapper around external API as a module with several methods. The question is: what is the right way to use async httpx client? option 1 or 2? Option1 (use global session)mywrapper.py _client = httpx.AsyncClient()
async def method1():
await _client.METHOD()
async def method2():
await _client.METHOD() Option2 (create new session each time)mywrapper.py async def method1():
async with httpx.AsyncClient() as client:
await client.METHOD()
async def method2():
async with httpx.AsyncClient() as client:
await client.METHOD() Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
johtso
May 23, 2021
Replies: 1 comment 1 reply
-
You might be interested in this discussion: #1552 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
tomchristie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You might be interested in this discussion: #1552