Skip to content

Commit

Permalink
Make async_http_retry_request_middleware default for AsyncHTTPProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
fselmo committed Jul 5, 2023
1 parent 4e9e17b commit 3368dde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web3/middleware/exception_retry_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def async_exception_retry_middleware(
) -> AsyncMiddlewareCoroutine:
"""
Creates middleware that retries failed HTTP requests.
Is a middleware for AsyncHTTPProvider.
Is a default middleware for AsyncHTTPProvider.
"""

async def middleware(method: RPCEndpoint, params: Any) -> Optional[RPCResponse]:
Expand Down
9 changes: 9 additions & 0 deletions web3/providers/async_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@
get_default_http_endpoint,
)
from web3.types import (
AsyncMiddleware,
RPCEndpoint,
RPCResponse,
)

from ..datastructures import (
NamedElementOnion,
)
from ..middleware.exception_retry_request import (
async_http_retry_request_middleware,
)
from .async_base import (
AsyncJSONBaseProvider,
)
Expand All @@ -40,6 +47,8 @@ class AsyncHTTPProvider(AsyncJSONBaseProvider):
logger = logging.getLogger("web3.providers.HTTPProvider")
endpoint_uri = None
_request_kwargs = None
# type ignored b/c conflict with _middlewares attr on AsyncBaseProvider
_middlewares: Tuple[AsyncMiddleware, ...] = NamedElementOnion([(async_http_retry_request_middleware, "http_retry_request")]) # type: ignore # noqa: E501

def __init__(
self,
Expand Down

0 comments on commit 3368dde

Please sign in to comment.