From aaecd0adaff7418533e99c81ca7232dd1f08c992 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 28 Jan 2018 20:30:31 -0600 Subject: [PATCH] added timeout to performget --- onionr/communicator.py | 2 +- onionr/core.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/onionr/communicator.py b/onionr/communicator.py index d7d92065..bdc11256 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -159,7 +159,7 @@ class OnionrCommunicate: if data != None: url = url + '&data=' + data try: - r = requests.get(url, headers=headers, proxies=proxies) + r = requests.get(url, headers=headers, proxies=proxies, timeout=(5, 30)) except requests.exceptions.RequestException as e: logger.warn(action + " failed with peer " + peer + ": " + str(e)) return False diff --git a/onionr/core.py b/onionr/core.py index 46f2a4ac..5a751fe3 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -166,6 +166,7 @@ class Core: dataHash = dataHash.decode() blockFileName = self.blockDataLocation + dataHash + '.dat' if os.path.exists(blockFileName): + return # to do, properly check if block is already saved elsewhere raise Exception("Data is already set for " + dataHash) else: blockFile = open(blockFileName, 'w')