Commit 4a764643 authored by Antoine Millet's avatar Antoine Millet
Browse files

Added timeout feature on (remote) call method.

parent 2daf7421
......@@ -211,7 +211,7 @@ class RpcConnection(object):
err = {'exception': error, 'message': message}
self._send_response(msg_id, error=err)
def call(self, method_name, *args, **kwargs): #TODO: timeout
def call(self, method_name, *args, **kwargs):
Make a new remote call on the peer.
......@@ -226,6 +226,12 @@ class RpcConnection(object):
seconds before to raise an :exc:`CallTimeout` exception if the peer
didnt respond.
if '_timeout' in kwargs:
timeout = kwargs['_timeout']
del kwargs['_timeout']
timeout = None
# Send the call to the peer:
msg_id = self._send_call(method_name, *args, **kwargs)
......@@ -235,7 +241,11 @@ class RpcConnection(object):
'event': threading.Event()}
# Wait for the response:
# Check if timeout occured:
if not self._calls[msg_id]['event'].is_set():
raise RpcError('TimeoutError', 'remote method timeout')
# Check if error occured while execution:
if self._calls[msg_id]['error'] is not None:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment