diff --git a/reportportal_client/__init__.py b/reportportal_client/__init__.py index adb7de70..b3ba68a7 100644 --- a/reportportal_client/__init__.py +++ b/reportportal_client/__init__.py @@ -20,3 +20,5 @@ ReportPortalService, ReportPortalServiceAsync, ) + +POST_LOGBATCH_RETRY_COUNT = 10 diff --git a/reportportal_client/service.py b/reportportal_client/service.py index 07d36055..c35bf310 100644 --- a/reportportal_client/service.py +++ b/reportportal_client/service.py @@ -20,6 +20,7 @@ import logging from .errors import ResponseError, EntryCreatedError, OperationCompletionError +from reportportal_client import POST_LOGBATCH_RETRY_COUNT logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) @@ -291,7 +292,20 @@ def log_batch(self, log_data): ) )] files.extend(attachments) - r = self.session.post(url=url, files=files, verify=self.verify_ssl) + for i in range(POST_LOGBATCH_RETRY_COUNT): + try: + r = self.session.post( + url=url, + files=files, + verify=self.verify_ssl + ) + except KeyError: + if i < POST_LOGBATCH_RETRY_COUNT - 1: + continue + else: + raise + break + logger.debug("log_batch - Stack: %s", self.stack) logger.debug("log_batch response: %s", r.text)