Repository navigation
Notify class observers after batching signals - #3972
Merged
Merged
Conversation
Contributor
Author
|
The The branch is current with |
|
Performance benchmarks:
|
quaquel
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pre-PR Checklist
Summary
Deliver batched signals to class-level observers even when no instance-level observer is registered. Otherwise, a class-wide monitor receives ordinary agent updates but silently misses updates inside
batch().Bug / Issue
Fixes #3971. The issue includes a minimal reproducer: two batched assignments should produce one notification with the initial and final values, but currently produce none.
Implementation
Use
_has_subscribers()when dispatching aggregated signals, matching the ordinary notification path. It checks both subscription scopes, and_mesa_notify()already delivers to both. Aggregation stays unchanged.Testing
pytest tests/experimental/test_batching.py tests/experimental/test_mesa_signals.py -q: 68 passed.pytest tests/ --ignore=tests/visualization -Werror -Wdefault::PendingDeprecationWarning -q: 794 passed.pytest tests/visualization -Werror -Wdefault::PendingDeprecationWarning -q: 126 passed, including browser tests.The eight new cases produce two assertion failures and six passes against unchanged production code. Both failures are class-only observers with a net change. Coverage includes scalar and list observables, nested batches, mixed class/instance subscriptions, and no-net-change suppression.
Additional Notes
Local verification used Python 3.12.11 on macOS. Other supported platforms and Python versions are left to CI.