Fixed
- BREAKING: Restored weakref behavior for Effects that was accidentally removed in the August 2025 rewrite. Effects are now properly garbage collected when not assigned to a variable, as documented.
⚠️ Migration Warning
If you were relying on Effects persisting without storing a reference, your code will break.
Previously buggy behavior:
# Effect stayed alive even without assignment (BUG)
Effect(lambda: print(signal()))
signal.set(1) # This worked, but shouldn't haveCorrect behavior (0.21.2+):
# Effect is immediately GC'd without assignment
Effect(lambda: print(signal()))
signal.set(1) # Effect won't run - already garbage collected
# Store reference to keep Effect alive
effect = Effect(lambda: print(signal()))
signal.set(1) # Works correctlyAction required: Search your codebase for Effect( and ensure all Effects are either:
- Assigned to a variable:
self.effect = Effect(...) - Stored in a collection:
self.effects.append(Effect(...)) - Properly disposed when done:
effect.dispose()
This change prevents memory leaks in patterns like nested Effects and is consistent with the documented behavior.
Added
- Added
__del__method to Effect class to automatically run cleanup functions when Effects are garbage collected, preventing resource leaks even without explicitdispose()calls.
Full Changelog: 0.21.1...0.21.2