LRU1 commited on
Commit
68fb125
·
1 Parent(s): e04f2c1

avoid repetitive log placeholder

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -32,6 +32,7 @@ if run_btn and video_file:
32
  st.info("Processing started. This may take several minutes depending on video length …")
33
  # container for live log streaming
34
  log_container = st.container()
 
35
 
36
  # Run pipeline via subprocess to avoid blocking UI; capture logs
37
  with st.spinner("Running Lec2Note2 pipeline …"):
@@ -58,6 +59,7 @@ if run_btn and video_file:
58
  threading.Thread(target=_enqueue_output, args=(proc.stdout, log_queue), daemon=True).start()
59
 
60
  logs = ""
 
61
  while True:
62
  try:
63
  line = log_queue.get(timeout=0.1)
@@ -67,7 +69,12 @@ if run_btn and video_file:
67
  break
68
  continue
69
  logs += line
70
- log_container.code(logs, language="bash")
 
 
 
 
 
71
 
72
  result_code = proc.wait()
73
  if result_code != 0:
 
32
  st.info("Processing started. This may take several minutes depending on video length …")
33
  # container for live log streaming
34
  log_container = st.container()
35
+ log_placeholder = log_container.empty()
36
 
37
  # Run pipeline via subprocess to avoid blocking UI; capture logs
38
  with st.spinner("Running Lec2Note2 pipeline …"):
 
59
  threading.Thread(target=_enqueue_output, args=(proc.stdout, log_queue), daemon=True).start()
60
 
61
  logs = ""
62
+ line_count = 0
63
  while True:
64
  try:
65
  line = log_queue.get(timeout=0.1)
 
69
  break
70
  continue
71
  logs += line
72
+ line_count += 1
73
+ if line_count % 5 == 0: # update UI every 5 lines to reduce overhead
74
+ log_placeholder.code(logs, language="bash", height=300)
75
+
76
+ # final flush
77
+ log_placeholder.code(logs, language="bash", height=300)
78
 
79
  result_code = proc.wait()
80
  if result_code != 0: