Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Output.clear_output() to be thread-safe. #3261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ipywidgets/widgets/widget_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ def clear_output(self, *pargs, **kwargs):
wait: bool
If True, wait to clear the output until new output is
available to replace it. Default: False

If any parameters are given, then this should be run on the main thread,
because race conditions may occur if run from multiple threads. It is
safe to call this function without any arguments from multiple threads.
"""
with self:
clear_output(*pargs, **kwargs)
if not pargs and not kwargs:
self.outputs = ()
else:
with self:
clear_output(*pargs, **kwargs)

# PY3: Force passing clear_output and clear_kwargs as kwargs
def capture(self, clear_output=False, *clear_args, **clear_kwargs):
Expand Down