-
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
add flag to is_connected
to allow user to see why provider connection failed
#2912
Conversation
fc48a9c
to
78c5d0d
Compare
is_connected
to allow user to see why provider connection failedis_connected
to allow user to see why provider connection failed
0bec883
to
72dcab4
Compare
is_connected
to allow user to see why provider connection failedis_connected
to allow user to see why provider connection failed
72dcab4
to
2a59ab4
Compare
2a59ab4
to
691a44e
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 good! I had a naming nit, and one question about the cache size test, but feel free to take or leave!
docs/internals.rst
Outdated
@@ -101,13 +101,17 @@ setting the middlewares the provider should use. | |||
the JSON-RPC method being called. | |||
|
|||
|
|||
.. py:method:: BaseProvider.is_connected() | |||
.. py:method:: BaseProvider.is_connected(raise_if_false=False) |
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 finding raise_if_false
to be sort of hard to reason about. Maybe we could call this argument show_traceback
or show_stack_trace
or something along those lines instead?
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 like show_traceback
. Changed.
docs/internals.rst
Outdated
|
||
This function should return ``True`` or ``False`` depending on whether the | ||
provider should be considered *connected*. For example, an IPC socket | ||
based provider should return ``True`` if the socket is open and ``False`` | ||
if the socket is closed. | ||
|
||
If set to ``True``, the optional ``raise_if_false`` boolean should raise a |
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.
😄
If set to ``True``, the optional ``raise_if_false`` boolean should raise a | |
If set to ``True``, the optional ``raise_if_false`` boolean will raise a |
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.
fixed
@@ -83,5 +90,5 @@ async def test_user_provided_session() -> None: | |||
session = ClientSession() | |||
provider = AsyncHTTPProvider(endpoint_uri=URI) | |||
cached_session = await provider.cache_async_session(session) | |||
assert len(request._async_session_cache) == 1 | |||
assert len(request._async_session_cache) == 2 |
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.
Why do these changes increase the cache size?
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.
The is_connected
s I added were added to the cache. Updated to clear the cache at the end of the test.
2c115e4
to
19faa57
Compare
19faa57
to
06d6ee2
Compare
What was wrong?
w3.is_connected()
just returns True or False. It would be helpful to know why the connection failed if it is False.Closes #2910
How was it fixed?
Added a
raise_if_false
flag to theis_connected
method and a newProviderConnectionError
which inherits fromWeb3Exception
.While adding tests, did a little cleanup on other provider testing.
Todo:
Cute Animal Picture