eriknw / afar

Run code on a Dask cluster via a context manager or IPython magic
Other
30 stars 0 forks source link

Fix displaying of outputs #21

Closed eriknw closed 3 years ago

eriknw commented 3 years ago

Fix race condition when updating output from other threads.

This applies when running in a notebook and may be a bug in ipywidgets. ipywidgets.Output.clear_output() does not wait until the output is cleared, so we were printing new items, which got cleared when clear_output() finally took effect.

Also, update calls to ipywidgets.Output to not use it as a context manager. The new way is more thread-safe.

This seems to work pretty well in Jupyter Notebook. However, out.clear_output() doesn't always clear the output even with sufficiently long wait. I don't know why; this may warrant further investigation.

This hopefully fixes https://github.com/eriknw/afar/issues/20