maxon.finally_once

maxon.finally_once(func, *args, **kwargs)

Executes a function when the current scope is left.

Note

An optional parameter canRaise can be passed to notify that func may eventually raise.

Parameters
  • func (function(*args, **kwargs)) – Function to be called.

  • args (Any) – Optional arguments to be passed to func.

  • kwargs (Any) – Optional settings like canRaise to control if func can raise an exception.

cleanup = finally_once(lambda x: MyFunction(x), canRaise=False)