Skip to content

Commit 3f3b4b7

Browse files
committed
Compilation: Use try_execute on all major thread launchers
Tweak try_exec algo so it actually retries the wanted amount.
1 parent 58b63f3 commit 3f3b4b7

File tree

2 files changed

+15
-37
lines changed

2 files changed

+15
-37
lines changed

nimp/build.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
import nimp.sys.process
3636

3737

38-
def _try_excecute(command, max_attemtps=3, delay=5, time_out=120):
38+
def _try_excecute(command, cwd='.', capture_output=True, max_attemtps=5, delay=5, time_out=120):
3939
''' retry in case autoSDK or devenv cache fails us '''
40-
attempt = 1
40+
attempt = 0
4141
while attempt <= max_attemtps:
4242
retry = False
4343
start_time = time.time()
44-
result, output, err = nimp.sys.process.call(command, capture_output=True)
44+
result, output, err = nimp.sys.process.call(command, cwd=cwd, capture_output=True)
4545
time_passed = time.time() - start_time
4646

4747
if result != 0:
@@ -50,22 +50,25 @@ def _try_excecute(command, max_attemtps=3, delay=5, time_out=120):
5050
logging.error('Visual Studio appears to have failed')
5151
return False
5252

53-
if attempt > max_attemtps:
54-
logging.error('Max attempts reached, bailing...')
55-
return result
5653
if "ERROR: Unhandled exception: System." in output and ":\\autoSDK\\HostWin64\\" in output:
5754
logging.warn(f'AutoSDK error.')
5855
retry = True
59-
if "Package 'RoslynPackage' failed to load." in output or "Package 'Visual Studio Build Manager Package' failed to load." in output:
56+
if "Package 'RoslynPackage' failed to load" in output:
57+
logging.warn(f'Devenv cache error')
58+
retry = True
59+
if "Package 'Visual Studio Build Manager Package' failed to load" in output:
6060
logging.warn(f'Devenv cache error')
6161
retry = True
6262

6363
if retry:
64+
if attempt >= max_attemtps:
65+
logging.error('Max attempts reached, bailing...')
66+
return result
6467
if time_passed > time_out:
6568
logging.warn(f'Not retrying error that happened late in the process')
6669
return result
67-
logging.warn(f'Retrying : attempt {attempt} out of {max_attemtps}...')
6870
attempt += 1
71+
logging.warn(f'Retrying : attempt {attempt} out of {max_attemtps}...')
6972
time.sleep(delay)
7073
else:
7174
return result
@@ -111,11 +114,7 @@ def msbuild(project_file, platform_name, configuration, project=None,
111114
if additional_flags is not None:
112115
command += additional_flags
113116

114-
result, output, _ = nimp.sys.process.call(command, capture_output=needCapture)
115-
116-
if nimp.sys.platform.is_windows() and 'Cannot run if when setup is in progress.' in output:
117-
logging.error('Visual Studio appears to have failed')
118-
return False
117+
result = _try_excecute(command, capture_output=needCapture)
119118

120119
return result == 0
121120

nimp/unreal_engine/build.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -204,28 +204,7 @@ def _unreal_generate_project(env):
204204
else:
205205
command = ['/bin/sh', './GenerateProjectFiles.sh']
206206

207-
208-
# Inline this here - minimal change for now - for testing
209-
def _try_excecute(env, command, max_attemtps=3, delay=5, time_out=60):
210-
''' retry in cause autoSDK fails us '''
211-
attempt = 1
212-
while attempt <= max_attemtps:
213-
start_time = time.time()
214-
result, output, err = nimp.sys.process.call(command, cwd=env.unreal_dir, capture_output=True)
215-
time_passed = time.time() - start_time
216-
# We don't want to retry long processes and block build machines, just retry quick autoSDK errors.
217-
if time_passed > time_out:
218-
return result
219-
if result != 0 and "ERROR: Unhandled exception: System." in output and ":\\autoSDK\\HostWin64\\" in output:
220-
logging.info('AutoSDK issue, retrying : attempt {attempt} out of {max_attemtps}...'.format(**locals()))
221-
if attempt > max_attemtps:
222-
return result
223-
attempt += 1
224-
time.sleep(delay)
225-
else:
226-
return result
227-
228-
return _try_excecute(env, command)
207+
return nimp.build._try_excecute(command, cwd=env.unreal_dir)
229208

230209

231210
def _unreal_build_tool_ubt(env, tool, vs_version=None):
@@ -250,7 +229,7 @@ def _unreal_run_ubt(env, target, build_platform, build_configuration, vs_version
250229
if flags is not None:
251230
command += flags
252231

253-
return nimp.sys.process.call(command, cwd=env.unreal_dir) == 0
232+
return nimp.build._try_excecute(command, cwd=env.unreal_dir) == 0
254233

255234

256235
def _unreal_run_uat(env, target, build_platforms, flags=None):
@@ -267,7 +246,7 @@ def _unreal_run_uat(env, target, build_platforms, flags=None):
267246
if flags is not None:
268247
command += flags
269248

270-
return nimp.sys.process.call(command, cwd=env.unreal_dir) == 0
249+
return nimp.build._try_excecute(command, cwd=env.unreal_dir) == 0
271250

272251

273252
### Targets

0 commit comments

Comments
 (0)