Describe the bug
silent acceptance + later no-op due to weakref.
Expected behavior
schedule_event(lambda ...) should raise immediately with a clear error.
To Reproduce
from mesa import Model
m = Model()
state = {"x": 0}
m.schedule_event(lambda: state.__setitem__("x", state["x"] + 1), at=1.0)
m.run_for(2.0)
print(state["x"]) # observed: 0, expected: 1
Reproduction steps:
- Create a Model.
- Schedule an event with an inline lambda using
at=... (or after=...).
- Advance time with
run_for(...).
- Observe that side effects from the lambda do not occur.
Additional context
- This appears related to event callbacks being stored via weak references in mesa.time.events.Event.
- Named functions with a strong reference execute as expected.