rpc: make process_http_resp() non-async
This commit is contained in:
parent
aed8600931
commit
add9dd7850
2 changed files with 9 additions and 9 deletions
|
|
@ -53,7 +53,7 @@ class MoneroRPCClient(RPCClient):
|
|||
|
||||
async def call(self,method,*params,**kwargs):
|
||||
assert params == (), f'{type(self).__name__}.call() accepts keyword arguments only'
|
||||
return await self.process_http_resp(self.backend.run(
|
||||
return self.process_http_resp(await self.backend.run(
|
||||
payload = {'id': 0, 'jsonrpc': '2.0', 'method': method, 'params': kwargs },
|
||||
timeout = 3600, # allow enough time to sync ≈1,000,000 blocks
|
||||
host_path = '/json_rpc'
|
||||
|
|
@ -67,7 +67,7 @@ class MoneroRPCClientRaw(MoneroRPCClient):
|
|||
|
||||
async def call(self,method,*params,**kwargs):
|
||||
assert params == (), f'{type(self).__name__}.call() accepts keyword arguments only'
|
||||
return await self.process_http_resp(self.backend.run(
|
||||
return self.process_http_resp(await self.backend.run(
|
||||
payload = kwargs,
|
||||
timeout = self.timeout,
|
||||
host_path = f'/{method}'
|
||||
|
|
|
|||
14
mmgen/rpc.py
14
mmgen/rpc.py
|
|
@ -302,7 +302,7 @@ class RPCClient(MMGenObject):
|
|||
"""
|
||||
default call: call with param list unrolled, exactly as with cli
|
||||
"""
|
||||
return await self.process_http_resp(self.backend.run(
|
||||
return self.process_http_resp(await self.backend.run(
|
||||
payload = {'id': 1, 'jsonrpc': '2.0', 'method': method, 'params': params },
|
||||
timeout = timeout,
|
||||
host_path = self.make_host_path(wallet)
|
||||
|
|
@ -313,7 +313,7 @@ class RPCClient(MMGenObject):
|
|||
Make a single call with a list of tuples as first argument
|
||||
For RPC calls that return a list of results
|
||||
"""
|
||||
return await self.process_http_resp(self.backend.run(
|
||||
return self.process_http_resp(await self.backend.run(
|
||||
payload = [{
|
||||
'id': n,
|
||||
'jsonrpc': '2.0',
|
||||
|
|
@ -337,15 +337,15 @@ class RPCClient(MMGenObject):
|
|||
ret = []
|
||||
|
||||
while cur_pos < len(cmd_list):
|
||||
tasks = [self.process_http_resp(self.backend.run(
|
||||
tasks = [self.backend.run(
|
||||
payload = {'id': n, 'jsonrpc': '2.0', 'method': method, 'params': params },
|
||||
timeout = timeout,
|
||||
host_path = self.make_host_path(wallet)
|
||||
)) for n,(method,params) in enumerate(cmd_list[cur_pos:chunk_size+cur_pos],1)]
|
||||
) for n,(method,params) in enumerate(cmd_list[cur_pos:chunk_size+cur_pos],1)]
|
||||
ret.extend(await asyncio.gather(*tasks))
|
||||
cur_pos += chunk_size
|
||||
|
||||
return ret
|
||||
return [self.process_http_resp(r) for r in ret]
|
||||
|
||||
# Icall family of methods - indirect RPC call using CallSigs mechanism:
|
||||
# - 'timeout' and 'wallet' kwargs are passed to corresponding Call method
|
||||
|
|
@ -367,8 +367,8 @@ class RPCClient(MMGenObject):
|
|||
timeout = timeout,
|
||||
wallet = wallet )
|
||||
|
||||
async def process_http_resp(self,coro,batch=False):
|
||||
text,status = await coro
|
||||
def process_http_resp(self,run_ret,batch=False,json_rpc=True):
|
||||
text,status = run_ret
|
||||
if status == 200:
|
||||
dmsg_rpc(' RPC RESPONSE data ==>\n{}\n',text,is_json=True)
|
||||
if batch:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue