Skip to content

Commit

Permalink
Increase the post timeout for uploading
Browse files Browse the repository at this point in the history
With larger and larger amounts of data being uploaded by more modern DUTs and tester software, we are seeing runs taking even longer to upload and get responses from servers.

PiperOrigin-RevId: 654804315
  • Loading branch information
dbhatman authored and copybara-github committed Jul 22, 2024
1 parent 6060cd0 commit 900e793
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions openhtf/output/callbacks/mfg_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
import time
import zlib

from google.auth import credentials as credentials_lib
from google.auth.transport import requests
from google.oauth2 import service_account

from openhtf.output import callbacks
from openhtf.output.proto import guzzle_pb2
from openhtf.output.proto import test_runs_converter

from openhtf.output.proto import guzzle_pb2


class UploadFailedError(Exception):
"""Raised when an upload to mfg-inspector fails."""
Expand All @@ -34,20 +35,25 @@ class InvalidTestRunError(Exception):
"""Raised if test run is invalid."""


def _send_mfg_inspector_request(envelope_data, credentials, destination_url):
def _send_mfg_inspector_request(
envelope_data: bytes,
credentials: credentials_lib.Credentials,
destination_url: str,
):
"""Send upload http request. Intended to be run in retry loop."""
logging.info('Uploading result...')

with requests.AuthorizedSession(credentials) as authed_session:
response = authed_session.request(
'POST', destination_url, data=envelope_data)
'POST', destination_url, data=envelope_data, timeout=60 * 5
)

try:
result = response.json()
except Exception:
except Exception as e:
logging.warning('Upload failed with response %s: %s', response,
response.text)
raise UploadFailedError(response, response.text)
raise UploadFailedError(response, response.text) from e

if response.status_code == 200:
return result
Expand Down

0 comments on commit 900e793

Please sign in to comment.