scripts/rpc: increment JSON RPC request id between calls
This allows sending multiple requests without waiting for response in next patches. Change-Id: I1a54313fbf6b18e1887febc7648e5b9cd8cf06ff Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/435475 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
f7cb69cb60
commit
88a2ee92dc
@ -16,6 +16,7 @@ class JSONRPCClient(object):
|
|||||||
def __init__(self, addr, port=None, verbose=False, timeout=60.0):
|
def __init__(self, addr, port=None, verbose=False, timeout=60.0):
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
self.request_id = 0
|
||||||
try:
|
try:
|
||||||
if addr.startswith('/'):
|
if addr.startswith('/'):
|
||||||
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
@ -36,10 +37,11 @@ class JSONRPCClient(object):
|
|||||||
self.sock.close()
|
self.sock.close()
|
||||||
|
|
||||||
def call(self, method, params={}, verbose=False):
|
def call(self, method, params={}, verbose=False):
|
||||||
|
self.request_id += 1
|
||||||
req = {}
|
req = {}
|
||||||
req['jsonrpc'] = '2.0'
|
req['jsonrpc'] = '2.0'
|
||||||
req['method'] = method
|
req['method'] = method
|
||||||
req['id'] = 1
|
req['id'] = self.request_id
|
||||||
if (params):
|
if (params):
|
||||||
req['params'] = params
|
req['params'] = params
|
||||||
reqstr = json.dumps(req)
|
reqstr = json.dumps(req)
|
||||||
|
Loading…
Reference in New Issue
Block a user