daKhosa commited on
Commit
f5b01ae
·
1 Parent(s): deab82a

Capture stderr (tqdm/progress) in log stream alongside stdout

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -202,15 +202,19 @@ def generate_video(image, prompt, resolution, steps, guidance_scale, seconds, se
202
  result_box = [None]
203
  error_box = [None]
204
  real_out = sys.stdout
 
205
 
206
  def _run():
207
- sys.stdout = _QueueWriter(log_q, real_out)
 
 
208
  try:
209
  result_box[0] = session.run_task(task)
210
  except Exception as exc:
211
  error_box[0] = exc
212
  finally:
213
  sys.stdout = real_out
 
214
  log_q.put(None) # sentinel
215
 
216
  t = threading.Thread(target=_run, daemon=True)
 
202
  result_box = [None]
203
  error_box = [None]
204
  real_out = sys.stdout
205
+ real_err = sys.stderr
206
 
207
  def _run():
208
+ writer = _QueueWriter(log_q, real_out)
209
+ sys.stdout = writer
210
+ sys.stderr = writer # tqdm and progress bars write to stderr
211
  try:
212
  result_box[0] = session.run_task(task)
213
  except Exception as exc:
214
  error_box[0] = exc
215
  finally:
216
  sys.stdout = real_out
217
+ sys.stderr = real_err
218
  log_q.put(None) # sentinel
219
 
220
  t = threading.Thread(target=_run, daemon=True)