Skip to content

[hmr] WeakDerived or something similar 🤔 #453

@CNSeniorious000

Description

@CNSeniorious000

For a standard reaction model:

##########  ---->  ###########  ---->  ##########
# Signal #         # Derived #         # Effect #
##########  < - -  ###########  < - -  ##########

A Derived referenced only by Signals is unreachable and should be GC’d, yet we can’t make every Signal → Derived reference weak or the Derived may vanish too soon.

Solution: give Derived an unsubscribe method that disposes it once no BaseComputation holds it.

Edit: or in a BaseComputation.__del__

We may also need to remind users not to treat Derived as a lazy Effect. But wait, then what can they use if they just need a lazy Effect? So we may implement a weak=False attribute in Derived and AsyncDerived to allow user control the lifespan of a Derived (just like we provide force_flush=True for Batchs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions