@@ -96,6 +96,23 @@ def original_load(self, *args: Any, **kwargs: Any) -> None:
9696 return original_load (self , * args , ** kwargs )
9797
9898
99+ class AsyncTransportProtocolErrorHandler (AsyncTransport ):
100+ """Retry on remote protocol error.
101+
102+ http://datatracker.ietf.org/doc/html/rfc2616#section-8.1.4 allows the server
103+ # to close the connection at any time, we treat this as a normal and try again
104+ # once since
105+ """
106+
107+ @retry_connection_error (attempts = 2 , exception = httpx .RemoteProtocolError )
108+ async def post (self , address , message , headers ):
109+ return await super ().post (address , message , headers )
110+
111+ @retry_connection_error (attempts = 2 , exception = httpx .RemoteProtocolError )
112+ async def get (self , address , params , headers ):
113+ return await super ().get (address , params , headers )
114+
115+
99116async def _cached_document (url : str ) -> Document :
100117 """Load external XML document from disk."""
101118 if url in _DOCUMENT_CACHE :
@@ -225,7 +242,7 @@ def __init__(
225242 self .transport = (
226243 AsyncTransport (client = client , wsdl_client = wsdl_client )
227244 if no_cache
228- else AsyncTransport (
245+ else AsyncTransportProtocolErrorHandler (
229246 client = client , wsdl_client = wsdl_client , cache = SqliteCache ()
230247 )
231248 )
0 commit comments