Skip to content

Commit f37bb30

Browse files
authored
Merge pull request #3642 from maartenbreddels/fix_no_hold_sync_during_set_state
fix: do not hold sync during set_state
2 parents 2af0cc4 + e6199d9 commit f37bb30

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
@@ -640,7 +640,7 @@ def set_state(self, sync_data):
640640
# The order of these context managers is important. Properties must
641641
# be locked when the hold_trait_notification context manager is
642642
# released and notifications are fired.
643-
with self.hold_sync(), self._lock_property(**sync_data), self.hold_trait_notifications():
643+
with self._lock_property(**sync_data), self.hold_trait_notifications():
644644
for name in sync_data:
645645
if name in self.keys:
646646
from_json = self.trait_metadata(name, 'from_json',

0 commit comments

Comments
 (0)