diff --git a/deluge_client/client.py b/deluge_client/client.py index 246da5c..574e518 100644 --- a/deluge_client/client.py +++ b/deluge_client/client.py @@ -48,14 +48,13 @@ class RemoteException(DelugeClientException): class DelugeRPCClient(object): - timeout = 20 - - def __init__(self, host, port, username, password, decode_utf8=False, automatic_reconnect=True): + def __init__(self, host, port, username, password, decode_utf8=False, automatic_reconnect=True, timeout=20): self.host = host self.port = port self.username = username self.password = password self.deluge_version = None + self.timeout = timeout # This is only applicable if deluge_version is 2 self.deluge_protocol_version = None @@ -173,6 +172,9 @@ def _receive_response(self, deluge_version, protocol_version, partial_data=b''): except ssl.SSLError: raise CallTimeoutException() + if len(d) == 0: + raise ConnectionLostException() + data += d if deluge_version == 2: if expected_bytes is None: