Skip to content

Commit f32bf82

Browse files
committed
[WIP] adapt sleep interval, dont recreate the layout so much
1 parent 0fb4af1 commit f32bf82

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pyhdtoolkit/scripts/htc_monitor.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ def main(
150150
"""
151151
# Configure our logger and level (only for functions, not rich Console)
152152
config_logger(level=log_level)
153+
sleep_interval = float(min(0.1, 1 / refresh))
153154

154155
# Create re-usable console and progress bar
155156
console: Console = Console()
156157
progress: Progress = Progress(
157-
TextColumn("Next HTCondor query"),
158+
TextColumn("[bold]Next HTCondor query[/bold]"),
158159
BarColumn(),
159160
TimeRemainingColumn(),
160161
console=console,
161-
transient=True,
162162
)
163163
task_id: TaskID = progress.add_task("waiting", total=wait)
164164

@@ -180,7 +180,8 @@ def main(
180180
progress.update(task_id, total=wait, completed=0)
181181

182182
# We start rendering our layout with progress + table
183-
live.update(make_layout(progress, table))
183+
layout: Layout = make_layout(progress, table)
184+
live.update(layout)
184185

185186
# Now we need to update the progress bar until we have
186187
# waited long enough for the next query
@@ -190,10 +191,14 @@ def main(
190191
progress.update(task_id, completed=min(elapsed, wait))
191192

192193
# Refresh the live display for the progress bar
193-
live.update(make_layout(progress, table))
194+
live.refresh()
194195

195196
# And sleep a little
196-
time.sleep(refresh)
197+
time.sleep(sleep_interval)
198+
199+
# This is to force a clean 100% completion render before resetting
200+
progress.update(task_id, completed=wait)
201+
live.refresh()
197202

198203
# In case the 'condor_q' command failed
199204
except CondorQError as err:

0 commit comments

Comments
 (0)