param.reactive.reactive_ops.dispose#

reactive_ops.dispose(cascade: builtins.bool = True) → None[source]#

Release the invalidation watchers this expression attached to its upstream Parameterized sources, instead of waiting for it to be garbage collected.

Raises if the expression still has a reader, another node built from it or a live watch() on it (call unwatch() first), rather than leaving that reader looking at a value that has stopped updating. If this was the only reader of one of its inputs, that input is disposed too; one still read elsewhere is left alone. cascade=False disposes only this expression, never its inputs, for a reader dispose() cannot see, e.g. a Parameter with allow_refs=True, or a bind()/pn.bind consumer. Either way, using a disposed expression afterwards (reading its value, or building a new one from it) raises rather than returning a stale value.

Whether an input actually gets disposed can depend on gc.collect() having run first: branching (b = a + 1) clones the input into a hidden reader that sits in a reference cycle only the cyclic collector can break.

A no-op if self does not wrap an rx expression, or if called more than once.

Examples

>>> import param
>>> a = param.rx(1)
>>> b = a + 1
>>> b.rx.dispose()