interface: forward errors
This commit is contained in:
parent
9af2c20706
commit
dd849964d1
|
@ -82,10 +82,6 @@ class TcpInterface(threading.Thread):
|
|||
error = response.get('error')
|
||||
result = response.get('result')
|
||||
|
||||
if error:
|
||||
print_error("received error:", response)
|
||||
return
|
||||
|
||||
if msg_id is not None:
|
||||
with self.lock:
|
||||
method, params, _id, queue = self.unanswered_requests.pop(msg_id)
|
||||
|
@ -114,7 +110,10 @@ class TcpInterface(threading.Thread):
|
|||
self.is_ping = False
|
||||
return
|
||||
|
||||
queue.put((self, {'method':method, 'params':params, 'result':result, 'id':_id}))
|
||||
if error:
|
||||
queue.put((self, {'method':method, 'params':params, 'error':error, 'id':_id}))
|
||||
else:
|
||||
queue.put((self, {'method':method, 'params':params, 'result':result, 'id':_id}))
|
||||
|
||||
|
||||
def get_socket(self):
|
||||
|
|
|
@ -109,6 +109,7 @@ class NetworkProxy(threading.Thread):
|
|||
|
||||
msg_id = response.get('id')
|
||||
result = response.get('result')
|
||||
error = response.get('error')
|
||||
if msg_id is not None:
|
||||
with self.lock:
|
||||
method, params, callback = self.unanswered_requests.pop(msg_id)
|
||||
|
@ -125,7 +126,7 @@ class NetworkProxy(threading.Thread):
|
|||
return
|
||||
|
||||
|
||||
r = {'method':method, 'params':params, 'result':result, 'id':msg_id}
|
||||
r = {'method':method, 'params':params, 'result':result, 'id':msg_id, 'error':error}
|
||||
callback(r)
|
||||
|
||||
|
||||
|
@ -171,11 +172,11 @@ class NetworkProxy(threading.Thread):
|
|||
while ids:
|
||||
r = queue.get(True, timeout)
|
||||
_id = r.get('id')
|
||||
if _id in ids:
|
||||
ids.remove(_id)
|
||||
res[_id] = r.get('result')
|
||||
else:
|
||||
raise
|
||||
ids.remove(_id)
|
||||
if r.get('error'):
|
||||
return BaseException(r.get('error'))
|
||||
result = r.get('result')
|
||||
res[_id] = r.get('result')
|
||||
out = []
|
||||
for _id in id2:
|
||||
out.append(res[_id])
|
||||
|
|
Loading…
Reference in New Issue