Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ca6284

Browse files
authored
iOS,macOS: delete run_command_with_retry (#167908)
`//build/mac/find_sdk.py` and `//build/config/ios/ios_sdk.py` contain a copy-pasted function to run a given command with a specified number of retries and a timeout. This code was added in flutter/buildroot#876 in response to timeouts on the mac bots in relation to #157636, and is no longer necessary. This is a pre-factoring patch to reduce the size of the upcoming merge of iOS and macOS SDK config/resolving infrastructure. No tests, since this is a refactor with no change in functionality. Issue: #167592 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 05f09c9 commit 2ca6284

File tree

2 files changed

+3
-48
lines changed

2 files changed

+3
-48
lines changed

engine/src/build/config/ios/ios_sdk.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# found in the LICENSE file.
44

55
import argparse
6-
import errno
76
import os
87
import shutil
98
import subprocess
@@ -22,28 +21,6 @@
2221
))
2322

2423

25-
def run_command_with_retry(command, timeout=10, retries=3):
26-
"""
27-
Runs a command using subprocess.check_output with timeout and retry logic.
28-
29-
Args:
30-
command: A list representing the command and its arguments.
31-
timeout: The maximum time (in seconds) to wait for each command execution.
32-
retries: The number of times to retry the command if it times out.
33-
34-
Returns:
35-
The output of the command as a bytes object if successful, otherwise
36-
raises a CalledProcessError.
37-
"""
38-
for attempt in range(1, retries + 1):
39-
try:
40-
result = subprocess.check_output(command, timeout=timeout)
41-
return result.decode('utf-8').strip()
42-
except subprocess.TimeoutExpired:
43-
if attempt >= retries:
44-
raise # Re-raise the TimeoutExpired error after all retries
45-
46-
4724
def main(argv):
4825
parser = argparse.ArgumentParser()
4926
parser.add_argument(
@@ -98,7 +75,7 @@ def main(argv):
9875
sdk,
9976
'--show-sdk-path',
10077
]
101-
sdk_output = run_command_with_retry(command, timeout=300)
78+
sdk_output = subprocess.check_output(command, timeout=300).decode('utf-8').strip()
10279
if symlink_path:
10380
symlink_target = os.path.join(sdks_path, os.path.basename(sdk_output))
10481
symlink(sdk_output, symlink_target)

engine/src/build/mac/find_sdk.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,6 @@ def parse_version(version_str):
3131
return [int(x) for x in re.findall(r'(\d+)', version_str)]
3232

3333

34-
def run_command_with_retry(command, timeout=10, retries=3):
35-
"""
36-
Runs a command using subprocess.check_output with timeout and retry logic.
37-
38-
Args:
39-
command: A list representing the command and its arguments.
40-
timeout: The maximum time (in seconds) to wait for each command execution.
41-
retries: The number of times to retry the command if it times out.
42-
43-
Returns:
44-
The output of the command as a bytes object if successful, otherwise
45-
raises a CalledProcessError.
46-
"""
47-
for attempt in range(1, retries + 1):
48-
try:
49-
result = subprocess.check_output(command, timeout=timeout)
50-
return result.decode('utf-8').strip()
51-
except subprocess.TimeoutExpired:
52-
if attempt >= retries:
53-
raise # Re-raise the TimeoutExpired error after all retries
54-
55-
5634
def main():
5735
parser = OptionParser()
5836
parser.add_option("--print_sdk_path",
@@ -91,7 +69,7 @@ def main():
9169
'if you are using Xcode 4.') % job.returncode)
9270

9371
# Locate the host toolchain.
94-
xcode_dir = run_command_with_retry(['xcode-select', '-print-path'], timeout=300)
72+
xcode_dir = subprocess.check_output(['xcode-select', '-print-path'], timeout=300).decode('utf-8').strip()
9573
toolchain_dir = os.path.join(xcode_dir, 'Toolchains/XcodeDefault.xctoolchain')
9674

9775
# Locate the target SDK.
@@ -101,7 +79,7 @@ def main():
10179
'macosx',
10280
'--show-sdk-path',
10381
]
104-
sdk_output = run_command_with_retry(sdk_command, timeout=300)
82+
sdk_output = subprocess.check_output(sdk_command, timeout=300).decode('utf-8').strip()
10583
if symlink_path:
10684
sdks_path = os.path.join(symlink_path, 'SDKs')
10785
# Symlink the host toolchain.

0 commit comments

Comments
 (0)