Skip to content

Commit

Permalink
Merge pull request #42 from dsander/connection-detection
Browse files Browse the repository at this point in the history
Detect broken connections / make timeout configurable
  • Loading branch information
JohnDoee authored Feb 17, 2024
2 parents 0e2583a + eb67b6f commit 052275e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions deluge_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -179,6 +178,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:
Expand Down

0 comments on commit 052275e

Please sign in to comment.