Make event triggering robust to (un)registration. #9453

Merged
merged 1 commit into from May 12, 2016

Projects

None yet

4 participants

@craigcitro
Contributor

Event callbacks can register or unregister new callbacks for the same event
while executing, and the previous triggering implementation allowed for event
callbacks to be inadvertently skipped.

The fix is to make a copy of the list of callbacks before executing any of
them. With this change, the resulting semantics are simple: any callbacks
registered before triggering are executed, and any new callbacks registered
are only visible at the next triggering of the event.

Note that this could potentially break existing callers who expected
newly-appended callbacks were immediately executed.

Fixes #9447. Originally based on a patch by @marksandler2.

PTAL @takluyver

@craigcitro
Contributor

I should say -- I don't know if this merits a note in the whatsnew/pr dir, but happy to add one if so.

@takluyver
Member

Thanks Craig. Yes, it would be good to have a whatsnew note. :-)

@minrk minrk added this to the 4.3 milestone May 11, 2016
@craigcitro
Contributor

Added a whatsnew note -- PTAL!

@craigcitro craigcitro Make event triggering robust to (un)registration.
Event callbacks can register or unregister new callbacks for the same event
while executing, and the previous triggering implementation allowed for event
callbacks to be inadvertently skipped.

The fix is to make a copy of the list of callbacks before executing any of
them. With this change, the resulting semantics are simple: any callbacks
registered before triggering are executed, and any new callbacks registered
are only visible at the next triggering of the event.

Note that this could potentially break existing callers who expected
newly-appended callbacks were immediately executed.

Fixes #9447. Originally based on a patch by @marksandler2.
68860ee
@minrk minrk merged commit a85ccde into ipython:master May 12, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@takluyver
Member
takluyver commented May 12, 2016 edited

Thanks Craig

@Carreau Carreau modified the milestone: 4.3, 5.0 Jun 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment