From 976da66aae96826e705786599c7c54121a644466 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 27 Aug 2021 21:08:17 -0500 Subject: [PATCH] Sometimes for output to clear in JupyterLab (don't know why) --- afar/_printing.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/afar/_printing.py b/afar/_printing.py index 629a46b..465870f 100644 --- a/afar/_printing.py +++ b/afar/_printing.py @@ -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)