-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async HTTP Provider #1978
Async HTTP Provider #1978
Conversation
I still have some typing to work out, but would love to get some feedback on general shape! This is the MVP implementation with absolutely nothing fancy - no middleware, no session caching, etc. I'll put those features in separate PRs! |
3208e26
to
5a76a89
Compare
|
||
@pytest.mark.asyncio | ||
async def test_isConnected(self, async_w3_http: "Web3") -> None: | ||
assert await async_w3_http.isConnected() is True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a mypy error on this line:
Incompatible types in "await" (actual type "bool", expected type "Awaitable[Any]")
And I'm not sure how to fix it. I think it should be a bool
, but I'm not sure where/why it thinks it should be an Awaitable[Any]
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe what this line is actually doing is assert await (async_w3_http.isConnected() is True)
The await
may not be applied before the is True
causing this to be a boolean being fed to an await statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe because of the decorator, I guess? Try adding @overload
cd2c442
to
3b3f51c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 structure looks fine (and sane enough).
|
||
@pytest.mark.asyncio | ||
async def test_isConnected(self, async_w3_http: "Web3") -> None: | ||
assert await async_w3_http.isConnected() is True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe what this line is actually doing is assert await (async_w3_http.isConnected() is True)
The await
may not be applied before the is True
causing this to be a boolean being fed to an await statement?
|
||
@property | ||
async def gas_price(self) -> Wei: | ||
# types ignored b/c mypy conflict with BlockingEth properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is unfortunate and would be nice to resolve... but I'm not sure what to suggest.
3b3f51c
to
9cee725
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great start! 🚀
A preliminary benchmark:
[sync] 30 eth_gas calls: 2.4563300249999998
[async] 30 eth_gas calls: 0.4444956649999998
Will see about getting a benchmark PR up next week.
f9db8fe
to
1a32209
Compare
What was wrong?
Adds a bare bones async http provider. No middleware yet, and no session caching.
Related to Issue #1413
Todo:
Cute Animal Picture