Skip to content

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

Merged
minrk merged 1 commit into
ipython:masterfrom
craigcitro:iteration
May 12, 2016
Merged

Make event triggering robust to (un)registration.#9453
minrk merged 1 commit into
ipython:masterfrom
craigcitro:iteration

Conversation

@craigcitro

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Contributor Author

Added a whatsnew note -- PTAL!

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 ipython#9447. Originally based on a patch by @marksandler2.
@minrk minrk merged commit a85ccde into ipython:master May 12, 2016
@takluyver

takluyver commented May 12, 2016

Copy link
Copy Markdown
Member

Thanks Craig

@Carreau Carreau modified the milestones: 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event callbacks which register/unregister other callbacks lead to surprising behavior

4 participants