- attempt to make more strict timeout

This commit is contained in:
Dmytro Bogovych 2023-08-22 17:32:59 +03:00
parent c5ded800b9
commit 26098649f2
1 changed files with 4 additions and 5 deletions

View File

@ -222,14 +222,13 @@ class QualtestBackend:
url = utils.join_host_and_path(self.address, "/play_audio/?") + params
# Get response from server
response = urllib.request.urlopen(url, timeout=utils.NETWORK_TIMEOUT)
if response.getcode() != 200:
utils.log_error("Failed to get audio. Error code: %s" % response.getcode())
response = requests.get(url, timeout=(utils.NETWORK_TIMEOUT, 5))
if response.status_code != 200:
utils.log_error("Failed to get audio. Error code: %s" % response.status_code)
return False
audio_content = response.read()
with open (output_path, 'wb') as f:
f.write(audio_content)
f.write(response.content)
return True
except Exception as err: