From 86fe6bb5fa5056cbf824f01dde6f157050684994 2020-10-20 16:30:28 From: Matthias Bussonnier Date: 2020-10-20 16:30:28 Subject: [PATCH] Backport PR #12625: Don't register the same callback multiple times --- diff --git a/IPython/core/events.py b/IPython/core/events.py index 6ebd790..1af13ca 100644 --- a/IPython/core/events.py +++ b/IPython/core/events.py @@ -60,7 +60,8 @@ class EventManager(object): if not callable(function): raise TypeError('Need a callable, got %r' % function) callback_proto = available_events.get(event) - self.callbacks[event].append(callback_proto.adapt(function)) + if function not in self.callbacks[event]: + self.callbacks[event].append(callback_proto.adapt(function)) def unregister(self, event, function): """Remove a callback from the given event."""