niligulmohar/python-symmetric-jsonrpc — Issue #7: defect: RPCClient.request can wait forever
Author: kroeplin
Created: 2011-11-22 16:15:19+00:00
State: open

The method 'request' of the class 'RPCClient' in 'rpc.py' has a problem in the following code:

with self._recv_waiting[request_id]['condition']:
self._recv_waiting[request_id]['condition'].wait(timeout)

When the response is received immediately after sending the request, the 'notifyAll()' can precede the 'wait(...)' that will then wait forever.

Either extend the range of the condition lock (not so easy with the 'wait_for_response' option) or wait only if no response has been received in the meantime:

with self._recv_waiting[request_id]['condition']:
if self._recv_waiting[request_id]['result'] is None:
self._recv_waiting[request_id]['condition'].wait(timeout)