Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry POSTing logs if KeyError occurs on iterating over env variables #40

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions reportportal_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
ReportPortalService,
ReportPortalServiceAsync,
)

POST_LOGBATCH_RETRY_COUNT = 10
16 changes: 15 additions & 1 deletion reportportal_client/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)

Expand Down