Summary
XhrIo accepts an optional injected httpx.AsyncClient, but close() always calls self._client.aclose().
Why this is a problem
If an application passes a shared httpx.AsyncClient into XhrIo, closing that helper unexpectedly shuts down the shared client and breaks unrelated requests.
Where
src/python_webchannel/xhr.py
Expected behavior
XhrIo should mirror the same ownership pattern recommended for WebChannel: only close an internally-created client, and leave caller-owned clients open.
Suggested fix
Track client ownership in __init__ (for example, self._owns_client = client is None) and only call aclose() from close() when the client was created internally.
Impact
This makes XhrIo unsafe to use with shared HTTP client pools, which is a common pattern in async Python applications.
Summary
XhrIoaccepts an optional injectedhttpx.AsyncClient, butclose()always callsself._client.aclose().Why this is a problem
If an application passes a shared
httpx.AsyncClientintoXhrIo, closing that helper unexpectedly shuts down the shared client and breaks unrelated requests.Where
src/python_webchannel/xhr.pyExpected behavior
XhrIoshould mirror the same ownership pattern recommended forWebChannel: only close an internally-created client, and leave caller-owned clients open.Suggested fix
Track client ownership in
__init__(for example,self._owns_client = client is None) and only callaclose()fromclose()when the client was created internally.Impact
This makes
XhrIounsafe to use with shared HTTP client pools, which is a common pattern in async Python applications.