param.reactive.reactive_ops.dispose#
- reactive_ops.dispose(cascade: builtins.bool = True) None[source]#
Release the invalidation watchers this expression attached to its upstream
Parameterizedsources, 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 (callunwatch()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=Falsedisposes only this expression, never its inputs, for a readerdispose()cannot see, e.g. aParameterwithallow_refs=True, or abind()/pn.bindconsumer. 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
selfdoes not wrap anrxexpression, or if called more than once.Examples
>>> import param >>> a = param.rx(1) >>> b = a + 1 >>> b.rx.dispose()