Skip to content

Commit

Permalink
Update manager request function for single provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjw committed Jan 13, 2019
1 parent 8612dbf commit 2815866
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions web3/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,18 @@ def default_middlewares(web3):
# Provider requests and response
#
def _make_request(self, method, params):
if self.provider:
request_func = self.provider.request_func(self.web3, tuple(self.middleware_stack))
self.logger.debug("Making request. Method: %s", method)
return request_func(method, params)
else:
raise UnhandledRequest(
"No provider available to respond to the RPC request:\n"
"method:{0}\n"
"params:{1}\n".format(
method,
params,
)
)
request_func = self.provider.request_func(
self.web3,
tuple(self.middleware_stack))
self.logger.debug("Making request. Method: %s", method)
return request_func(method, params)

async def _coro_make_request(self, method, params):
for provider in self.providers:
request_func = provider.request_func(self.web3, tuple(self.middleware_stack))
self.logger.debug("Making request. Method: %s", method)
try:
return await request_func(method, params)
except CannotHandleRequest:
continue
else:
raise UnhandledRequest(
"No providers responded to the RPC request:\n"
"method:{0}\n"
"params:{1}\n".format(
method,
params,
)
)
request_func = self.provider.request_func(
self.web3,
tuple(self.middleware_stack))
self.logger.debug("Making request. Method: %s", method)
return await request_func(method, params)

def request_blocking(self, method, params):
"""
Expand Down

0 comments on commit 2815866

Please sign in to comment.