Skip to content

Commit 702d48c

Browse files
committed
WIP Remove code about sending echo messages combined with any kernel updates
1 parent 6eff179 commit 702d48c

File tree

1 file changed

+2
-49
lines changed
  • python/ipywidgets/ipywidgets/widgets

1 file changed

+2
-49
lines changed

python/ipywidgets/ipywidgets/widgets/widget.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,10 @@ def get_view_spec(self):
429429
def _default_keys(self):
430430
return [name for name in self.traits(sync=True)]
431431

432-
_property_lock = Dict() # only used when JUPYTER_WIDGETS_ECHO=0
432+
_property_lock = Dict()
433433
_holding_sync = False
434-
_holding_sync_from_frontend_update = False
435434
_states_to_send = Set()
436435
_msg_callbacks = Instance(CallbackDispatcher, ())
437-
_updated_attrs_from_frontend = None
438436

439437
#-------------------------------------------------------------------------
440438
# (Con/de)structor
@@ -536,23 +534,9 @@ def send_state(self, key=None):
536534
for name, value in state.items():
537535
if name in self._property_lock:
538536
self._property_lock[name] = value
539-
540-
541-
echo_state = {}
542-
if self._updated_attrs_from_frontend:
543-
for attr in self._updated_attrs_from_frontend:
544-
echo_state[attr] = state[attr]
545-
del state[attr]
546-
self._updated_attrs_from_frontend = None
547537
state, buffer_paths, buffers = _remove_buffers(state)
548-
echo_state, echo_buffer_paths, echo_buffers = _remove_buffers(echo_state)
549538
msg = {'method': 'update', 'state': state, 'buffer_paths': buffer_paths}
550-
if echo_state or echo_buffer_paths:
551-
msg['echo_state'] = echo_state
552-
msg['echo_buffer_paths'] = echo_buffer_paths
553-
buffers += echo_buffers
554539
self._send(msg, buffers=buffers)
555-
return
556540

557541
def get_state(self, key=None, drop_defaults=False):
558542
"""Gets the widget state, or a piece of it.
@@ -663,18 +647,6 @@ def notify_change(self, change):
663647
# Send the state to the frontend before the user-registered callbacks
664648
# are called.
665649
name = change['name']
666-
if JUPYTER_WIDGETS_ECHO:
667-
if self.comm is not None and self.comm.kernel is not None and name in self.keys:
668-
if self._holding_sync:
669-
# if we're holding a sync, we will only record which trait was changed
670-
# but we skip those traits marked no_echo, during an update from the frontend
671-
if not (self._holding_sync_from_frontend_update and self.trait_metadata(name, 'no_echo')):
672-
self._states_to_send.add(name)
673-
else:
674-
# otherwise we send it directly
675-
self.send_state(key=name)
676-
super().notify_change(change)
677-
return
678650
if self.comm is not None and self.comm.kernel is not None:
679651
# Make sure this isn't information that the front-end just sent us.
680652
if name in self.keys and self._should_send_property(name, getattr(self, name)):
@@ -738,21 +710,6 @@ def _should_send_property(self, key, value):
738710
else:
739711
return True
740712

741-
@contextmanager
742-
def _hold_sync_frontend(self):
743-
"""Same as hold_sync, but will not sync back traits tagged as no_echo"""
744-
if self._holding_sync_from_frontend_update is True:
745-
with self.hold_sync():
746-
yield
747-
else:
748-
try:
749-
self._holding_sync_from_frontend_update = True
750-
with self.hold_sync():
751-
yield
752-
finally:
753-
self._holding_sync_from_frontend_update = False
754-
755-
756713
# Event handlers
757714
@_show_traceback
758715
def _handle_msg(self, msg):
@@ -774,11 +731,7 @@ def _handle_msg(self, msg):
774731
# Handle a custom msg from the front-end.
775732
elif method == 'custom':
776733
if 'content' in data:
777-
if JUPYTER_WIDGETS_ECHO:
778-
with self._hold_sync_frontend():
779-
self._handle_custom_msg(data['content'], msg['buffers'])
780-
else:
781-
self._handle_custom_msg(data['content'], msg['buffers'])
734+
self._handle_custom_msg(data['content'], msg['buffers'])
782735

783736
# Catch remainder.
784737
else:

0 commit comments

Comments
 (0)