Skip to content

Enforce callback parameters rules

Compare
Choose a tag to compare
@samuelgregorovic samuelgregorovic released this 02 Feb 22:20
· 17 commits to main since this release

In latest version of callpyback, when declaring callback functions, following rules must be obeyed:

a) on_call() callback MUST eitheraccept no parameters or combination of the following:

  • func_kwargs - will receive parameters passed to the function decorated with CallPyBack

b) on_success() callback MUST either accept no parameters or combination of the following:

  • func_result - will receive return value of the function decorated with CallPyBack
  • func_kwargs - will receive parameters passed to the function decorated with CallPyBack

c) on_failure() callback MUST either accept no parameters or combination of the following:

  • func_exception - will receive exception raised by the function decorated with CallPyBack
  • func_kwargs - will receive parameters passed to the function decorated with CallPyBack

d) on_end() callback MUST either accept no parameters or combination of the following:

  • func_result - will receive return value of the function decorated with CallPyBack
  • func_exception - will receive exception raised by the function decorated with CallPyBack
  • func_kwargs - will receive parameters passed to the function decorated with CallPyBack
  • func_scope_vars - will receive local variables of the function decorated with CallPyBack, whose names were specified in the pass_vars decorator parameter.

These rules are enforced to allow omitting parameters in the callback function. This is useful when some of these parameters are not needed for the callback function. If those rules are not obeyed, error will be raised during the initialization of the CallPyBack decorator class.