@@ -597,17 +597,23 @@ def _compare(self, a, b):
597
597
598
598
def set_state (self , sync_data ):
599
599
"""Called when a state is received from the front-end."""
600
+ # Send an echo update message immediately
600
601
if JUPYTER_WIDGETS_ECHO :
601
- with self ._hold_sync_frontend (), self .hold_trait_notifications ():
602
- # keep this as a list, not a set, since that preserves order (useful in the test)
603
- self ._updated_attrs_from_frontend = [name for name in sync_data if name in self .keys ]
604
- # TODO: this for-loop is the same as below. Only the context managers are different
605
- for name in sync_data :
606
- if name in self .keys :
607
- from_json = self .trait_metadata (name , 'from_json' ,
608
- self ._trait_from_json )
609
- self .set_trait (name , from_json (sync_data [name ], self ))
610
- return
602
+ echo_state = {}
603
+ for attr ,value in sync_data .items ():
604
+ if not self .trait_metadata (attr , 'no_echo' ):
605
+ echo_state [attr ] = value
606
+ if echo_state :
607
+ echo_state , echo_buffer_paths , echo_buffers = _remove_buffers (echo_state )
608
+ msg = {
609
+ 'method' : 'update' ,
610
+ 'state' : {},
611
+ 'buffer_paths' : [],
612
+ 'echo_state' : echo_state ,
613
+ 'echo_buffer_paths' : echo_buffer_paths
614
+ }
615
+ self ._send (msg , buffers = echo_buffers )
616
+
611
617
# The order of these context managers is important. Properties must
612
618
# be locked when the hold_trait_notification context manager is
613
619
# released and notifications are fired.
0 commit comments