Fix regression in set_timer, old events not removed #2769
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2763
This was a minor regression introduced in my older event refactor PRs that got merged in 2.0.1
Setting a timer for an event should discard older timers for the same event. While this behavior was not previously documented, this was the standard behaviour for a long time until 2.0.1 when my changes inadvertently changed behaviour here. (Funnily, I had documented this behaviour in the same PR I broke it 馃槄, I remember having tested it, but it somehow worked back then due to some test weirdness/randomness in the broken behaviour)
While having multiple timers for the same event running independently sounds like a good idea, this fix is needed for backwards compatibility of older code using this function.
This PR also updates the tests for this function.
Also what do y'all think of a keyword argument for this function, something like
remove_old_timer=True
, which can be set to false if someone wants to place in an event on the timer and not remove the older one?