Skip to content

Commit fa52cc6

Browse files
Add timeout to fcm_bdiff (#79)
With large changesets fcm_bdiff can fill the buffer, causing a hang - this is often seen with a non-appearing trac.log. This ticket adds a timeout to the fcm_bdiff subprocess, preventing the hang. This has been tested on a Apps branch with a large changeset.
1 parent e21c078 commit fa52cc6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

fcm_bdiff.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,20 @@ def run_fcm_command(command, max_retries, snooze):
177177
"""
178178
retries = 0
179179
while True:
180-
output = subprocess.Popen(
181-
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
180+
result = subprocess.run(
181+
command,
182+
capture_output=True,
183+
text=True,
184+
timeout=120,
185+
shell=False,
186+
check=False,
182187
)
183-
_ = output.wait()
184-
if output.returncode == 0:
185-
return text_decoder(output.stdout.read())
188+
if result.returncode == 0:
189+
return result.stdout
186190
else:
187191
retries += 1
188192
if retries > max_retries:
189-
raise FCMError(command, text_decoder(output.stderr.read()))
193+
raise FCMError(command, result.stderr)
190194
else:
191195
time.sleep(snooze)
192196

0 commit comments

Comments
 (0)