Skip to content

Commit

Permalink
Sometimes for output to clear in JupyterLab (don't know why)
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Aug 28, 2021
1 parent fb92e13 commit 976da66
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions afar/_printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ def print_outputs_async(out, stderr_future, repr_future, stdout_future):
try:
stdout_val = stdout_future.result()
out.clear_output()
count = 0
while out.outputs:
# See: https://github.com/jupyter-widgets/ipywidgets/issues/3260
count += 1
if count == 100: # 0.5 seconds
# This doesn't appear to always clear correctly in JupyterLab.
# I don't know why. I'm still investigating.
out.outputs = type(out.outputs)() # is this safe?
break
sleep(0.005)
if stdout_val:
out.append_stdout(stdout_val)
Expand Down

0 comments on commit 976da66

Please sign in to comment.