added timeout to performget

master
Kevin Froman 2018-01-28 20:30:31 -06:00
parent 8b3a09f5af
commit aaecd0adaf
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 2 additions and 1 deletions

View File

@ -159,7 +159,7 @@ class OnionrCommunicate:
if data != None: if data != None:
url = url + '&data=' + data url = url + '&data=' + data
try: 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: except requests.exceptions.RequestException as e:
logger.warn(action + " failed with peer " + peer + ": " + str(e)) logger.warn(action + " failed with peer " + peer + ": " + str(e))
return False return False

View File

@ -166,6 +166,7 @@ class Core:
dataHash = dataHash.decode() dataHash = dataHash.decode()
blockFileName = self.blockDataLocation + dataHash + '.dat' blockFileName = self.blockDataLocation + dataHash + '.dat'
if os.path.exists(blockFileName): if os.path.exists(blockFileName):
return # to do, properly check if block is already saved elsewhere
raise Exception("Data is already set for " + dataHash) raise Exception("Data is already set for " + dataHash)
else: else:
blockFile = open(blockFileName, 'w') blockFile = open(blockFileName, 'w')