-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added caching to the async session in request.py and AsyncHTTPProvider (
#2254) * Added caching to the async session in request.py and AsyncHTTPProvider
- Loading branch information
Showing
6 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added session caching to the AsyncHTTPProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
import pytest | ||
|
||
from aiohttp import ( | ||
ClientSession, | ||
) | ||
|
||
from web3._utils import ( | ||
request, | ||
) | ||
from web3.providers.async_rpc import ( | ||
AsyncHTTPProvider, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_user_provided_session() -> None: | ||
|
||
session = ClientSession() | ||
provider = AsyncHTTPProvider(endpoint_uri="http://mynode.local:8545") | ||
await provider.cache_async_session(session) | ||
assert len(request._async_session_cache) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters