Skip to content

Commit

Permalink
Enable missing-timeout pylint check (#28920)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmccluskey authored Oct 11, 2023
1 parent a54afde commit e56d1a1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
1 change: 0 additions & 1 deletion sdks/python/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ disable =
missing-docstring,
modified-iterating-list,
multiple-statements,
missing-timeout, #TODO(https://github.com/apache/beam/issues/28240) Enable and fix warnings
no-self-use,
no-else-break,
no-else-continue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def executable_jar(self):
return job_server.JavaJarJobServer.local_jar(url)

def flink_version(self):
full_version = requests.get('%s/v1/config' %
self._master_url).json()['flink-version']
full_version = requests.get(
'%s/v1/config' % self._master_url, timeout=60).json()['flink-version']
# Only return up to minor version.
return '.'.join(full_version.split('.')[:2])

Expand Down
20 changes: 16 additions & 4 deletions sdks/python/apache_beam/testing/analyzers/github_issues_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
_AWAITING_TRIAGE_LABEL = 'awaiting triage'
_PERF_ALERT_LABEL = 'perf-alert'

_REQUEST_TIMEOUT_SECS = 60


def create_issue(
title: str,
Expand Down Expand Up @@ -89,7 +91,10 @@ def create_issue(
if labels:
data['labels'].extend(labels) # type: ignore
response = requests.post(
url=url, data=json.dumps(data), headers=_HEADERS).json()
url=url,
data=json.dumps(data),
headers=_HEADERS,
timeout=_REQUEST_TIMEOUT_SECS).json()
return response['number'], response['html_url']


Expand Down Expand Up @@ -118,7 +123,8 @@ def comment_on_issue(issue_number: int,
'issue_number': issue_number
},
default=str),
headers=_HEADERS).json()
headers=_HEADERS,
timeout=_REQUEST_TIMEOUT_SECS).json()
if open_issue_response['state'] == 'open':
data = {
'owner': _GITHUB_REPO_OWNER,
Expand All @@ -128,7 +134,10 @@ def comment_on_issue(issue_number: int,
}

response = requests.post(
open_issue_response['comments_url'], json.dumps(data), headers=_HEADERS)
open_issue_response['comments_url'],
json.dumps(data),
headers=_HEADERS,
timeout=_REQUEST_TIMEOUT_SECS)
return True, response.json()['html_url']
return False, ''

Expand All @@ -137,7 +146,10 @@ def add_awaiting_triage_label(issue_number: int):
url = 'https://api.github.com/repos/{}/{}/issues/{}/labels'.format(
_GITHUB_REPO_OWNER, _GITHUB_REPO_NAME, issue_number)
requests.post(
url, json.dumps({'labels': [_AWAITING_TRIAGE_LABEL]}), headers=_HEADERS)
url,
json.dumps({'labels': [_AWAITING_TRIAGE_LABEL]}),
headers=_HEADERS,
timeout=_REQUEST_TIMEOUT_SECS)


def get_issue_description(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ def publish_performance_influxdb(self, query_num, perf):
auth = HTTPBasicAuth(user, password)

try:
response = requests.post(url, params=query_str, data=payload, auth=auth)
response = requests.post(
url, params=query_str, data=payload, auth=auth, timeout=60)
except requests.exceptions.RequestException as e:
logging.warning('Failed to publish metrics to InfluxDB: ' + str(e))
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ def publish(self, results):
self.options.http_auth_enabled() else None

try:
response = requests.post(url, params=query_str, data=payload, auth=auth)
response = requests.post(
url, params=query_str, data=payload, auth=auth, timeout=60)
except requests.exceptions.RequestException as e:
_LOGGER.warning('Failed to publish metrics to InfluxDB: ' + str(e))
else:
Expand Down

0 comments on commit e56d1a1

Please sign in to comment.