Skip to content

Commit 3fdf305

Browse files
committed
Update documentation for persistent connection providers refactor
1 parent d9f8df7 commit 3fdf305

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

docs/providers.rst

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ can be found in the `websockets connection`_ docs.
336336
... logger.setLevel(logging.DEBUG)
337337
... logger.addHandler(logging.StreamHandler())
338338
339-
>>> async def context_manager_subscriptions_example():
339+
>>> async def context_manager_subscription_example():
340340
... # async with AsyncWeb3(AsyncIPCProvider("./path/to.filename.ipc") as w3: # for the AsyncIPCProvider
341341
... async with AsyncWeb3(WebSocketProvider(f"ws://127.0.0.1:8546")) as w3: # for the WebSocketProvider
342342
... # subscribe to new block headers
@@ -482,17 +482,6 @@ Interacting with the Persistent Connection
482482
Examples on how to use this method can be seen above in the
483483
`Using Persistent Connection Providers`_ section.
484484

485-
.. py:method:: recv()
486-
487-
The ``recv()`` method can be used to receive the next message from the
488-
socket. The response from this method is formatted by web3.py formatters
489-
and run through the middleware before being returned. This is not the
490-
recommended way to receive a message as the ``process_subscriptions()`` method
491-
is available for listening to subscriptions and the standard API for making
492-
requests via the appropriate module
493-
(e.g. ``block_num = await w3.eth.block_number``) is available for receiving
494-
responses for one-to-one request-to-response calls.
495-
496485
.. py:method:: send(method: RPCEndpoint, params: Sequence[Any])
497486
498487
This method is available strictly for sending raw requests to the socket,
@@ -502,6 +491,25 @@ Interacting with the Persistent Connection
502491
module. For example, use ``w3.eth.get_block("latest")`` instead of
503492
``w3.socket.send("eth_getBlockByNumber", ["latest", True])``.
504493

494+
.. py:method:: recv()
495+
496+
The ``recv()`` method can be used to receive the next response for a request
497+
from the socket. The response from this method is the raw response. This is not
498+
the recommended way to receive a response for a request, as it is not formatted
499+
by *web3.py* formatters or run through the middleware. Instead, use the methods
500+
available on the respective web3 module
501+
(e.g. ``block_num = await w3.eth.block_number``) for retrieving responses for
502+
one-to-one request-to-response calls.
503+
504+
.. py:method:: make_request(method: RPCEndpoint, params: Sequence[Any])
505+
506+
This method is available for making requests to the socket and retrieving the
507+
response. It is not recommended to use this method directly, as the responses
508+
will not be properly formatted by *web3.py* formatters or run through the
509+
middleware. Instead, use the methods available on the respective web3 module.
510+
For example, use ``w3.eth.get_block("latest")`` instead of
511+
``w3.socket.make_request("eth_getBlockByNumber", ["latest", True])``.
512+
505513

506514
LegacyWebSocketProvider
507515
~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)