Skip to content

Commit 0772db0

Browse files
committed
Disable TetGen spinner in non-interactive environments
Wrap the tetrahedralize spinner loop in a sys.stdout.isatty() check so that interactive terminals still show progress, but CI/redirected output simply waits on the worker process without frequent stdout updates. This removes any potential overhead from the progress bar on Windows and macOS runners while TetGen runs in the background, confirming that spinner output is not contributing to slow tetrahedralization in CI.
1 parent 68cba15 commit 0772db0

File tree

1 file changed

+49
-42
lines changed

1 file changed

+49
-42
lines changed

svv/domain/routines/tetrahedralize.py

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -150,50 +150,57 @@ def tetrahedralize(surface: pv.PolyData,
150150
text=True, # decode to strings
151151
)
152152

153-
spinner = _spinner_cycle()
154-
start_time = time.time()
155-
156-
# Print label once
157-
sys.stdout.write("TetGen meshing| ")
158-
sys.stdout.flush()
159-
160-
# Live spinner loop
161-
while proc.poll() is None:
162-
# Compute elapsed time
163-
elapsed = time.time() - start_time
164-
elapsed_str = format_elapsed(elapsed)
165-
166-
# Build left side message
167-
spin_char = next(spinner)
168-
left = f"TetGen meshing| {spin_char}"
169-
170-
# Get terminal width (fallback if IDE doesn't report it)
171-
try:
172-
width = shutil.get_terminal_size(fallback=(80, 20)).columns
173-
except Exception:
174-
width = 80
175-
176-
# Compute spacing so elapsed time is right-aligned
177-
# We'll always keep at least one space between left and right
178-
min_gap = 1
179-
total_len = len(left) + min_gap + len(elapsed_str)
180-
if total_len <= width:
181-
spaces = width - len(left) - len(elapsed_str)
182-
else:
183-
# If line is longer than terminal, don't try to be clever; just put a single space
184-
spaces = min_gap
185-
186-
line = f"{left}{' ' * spaces}{elapsed_str}"
187-
188-
# '\r' to return to the start of the same line and overwrite
189-
sys.stdout.write("\r" + line)
190-
sys.stdout.flush()
153+
show_spinner = sys.stdout.isatty()
154+
if show_spinner:
155+
spinner = _spinner_cycle()
156+
start_time = time.time()
191157

192-
time.sleep(0.1)
158+
# Print label once
159+
sys.stdout.write("TetGen meshing| ")
160+
sys.stdout.flush()
193161

194-
# Finish line
195-
sys.stdout.write("\n")
196-
sys.stdout.flush()
162+
# Live spinner loop
163+
while proc.poll() is None:
164+
# Compute elapsed time
165+
elapsed = time.time() - start_time
166+
elapsed_str = format_elapsed(elapsed)
167+
168+
# Build left side message
169+
spin_char = next(spinner)
170+
left = f"TetGen meshing| {spin_char}"
171+
172+
# Get terminal width (fallback if IDE doesn't report it)
173+
try:
174+
width = shutil.get_terminal_size(fallback=(80, 20)).columns
175+
except Exception:
176+
width = 80
177+
178+
# Compute spacing so elapsed time is right-aligned
179+
# We'll always keep at least one space between left and right
180+
min_gap = 1
181+
total_len = len(left) + min_gap + len(elapsed_str)
182+
if total_len <= width:
183+
spaces = width - len(left) - len(elapsed_str)
184+
else:
185+
# If line is longer than terminal, don't try to be clever; just put a single space
186+
spaces = min_gap
187+
188+
line = f"{left}{' ' * spaces}{elapsed_str}"
189+
190+
# '\r' to return to the start of the same line and overwrite
191+
sys.stdout.write("\r" + line)
192+
sys.stdout.flush()
193+
194+
time.sleep(0.1)
195+
196+
# Finish line
197+
sys.stdout.write("\n")
198+
sys.stdout.flush()
199+
else:
200+
# Non-interactive environment (e.g., CI): just wait for the
201+
# worker process to finish without a live spinner to avoid
202+
# any potential overhead from frequent stdout updates.
203+
proc.wait()
197204

198205
# Collect output (so the pipes don't hang)
199206
stdout, stderr = proc.communicate()

0 commit comments

Comments
 (0)