Skip to content

Commit 05fc32f

Browse files
fix: do not hold sync during set_state
If we do, we get very inconsistent behaviour, see #3635 for more details and #3271 for the reasons to implement this.
1 parent 3ce6472 commit 05fc32f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

python/ipywidgets/ipywidgets/widgets/tests/test_set_state.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,13 @@ def _propagate_value(self, change):
287287
msg = {'method': 'echo_update', 'state': {'value': 42.0}, 'buffer_paths': []}
288288
call42 = mock.call(msg, buffers=[])
289289

290-
msg = {'method': 'update', 'state': {'value': 2.0, 'other': 11.0}, 'buffer_paths': []}
290+
msg = {'method': 'update', 'state': {'value': 2.0}, 'buffer_paths': []}
291291
call2 = mock.call(msg, buffers=[])
292292

293-
calls = [call42, call2] if echo else [call2]
293+
msg = {'method': 'update', 'state': {'other': 11.0}, 'buffer_paths': []}
294+
call11 = mock.call(msg, buffers=[])
295+
296+
calls = [call42, call2, call11] if echo else [call2, call11]
294297
widget._send.assert_has_calls(calls)
295298

296299

python/ipywidgets/ipywidgets/widgets/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def set_state(self, sync_data):
616616
# The order of these context managers is important. Properties must
617617
# be locked when the hold_trait_notification context manager is
618618
# released and notifications are fired.
619-
with self.hold_sync(), self._lock_property(**sync_data), self.hold_trait_notifications():
619+
with self._lock_property(**sync_data), self.hold_trait_notifications():
620620
for name in sync_data:
621621
if name in self.keys:
622622
from_json = self.trait_metadata(name, 'from_json',

0 commit comments

Comments
 (0)