From e0373146daa32e024101ea0ded31aeae68abbdb2 Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Mon, 20 Jun 2022 18:28:23 +0300 Subject: [PATCH] Possible fix for Sauce ConnectionResetError (#13501) --- test/appium/tests/conftest.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index 4ffc8246d5..d02ef31691 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -1,3 +1,5 @@ +import time + import requests import pytest import re @@ -178,11 +180,16 @@ def pytest_configure(config): response.raise_for_status() file = BytesIO(response.content) del response - requests.post('http://saucelabs.com/rest/v1/storage/' - + sauce_username + '/' + test_suite_data.apk_name + '?overwrite=true', - auth=(sauce_username, sauce_access_key), - data=file, - headers={'Content-Type': 'application/octet-stream'}) + for _ in range(3): + try: + requests.post('http://saucelabs.com/rest/v1/storage/' + + sauce_username + '/' + test_suite_data.apk_name + '?overwrite=true', + auth=(sauce_username, sauce_access_key), + data=file, + headers={'Content-Type': 'application/octet-stream'}) + break + except ConnectionError: + time.sleep(3) else: sauce.storage.upload_file(config.getoption('apk'))