Skip to content

signals.signal

callable_accepts_kwargs

1
callable_accepts_kwargs(func: Callable) -> bool

Checks if function accepts **kwargs.

Arguments:

  • func: function which signature needs to be checked :type func: function

Returns:

result of the check :rtype: bool

make_id

1
make_id(target: Any) -> Union[int, Tuple[int, int]]

Creates id of a function or method to be used as key to store signal

Arguments:

  • target: target which id we want :type target: Any

Returns:

id of the target :rtype: int

Signal Objects

1
class Signal()

Signal that notifies all receiver functions. In ormar used by models to send pre_save, post_save etc. signals.

connect

1
 | connect(receiver: Callable) -> None

Connects given receiver function to the signal.

Raises:

  • SignalDefinitionError: if receiver is not callable or not accept **kwargs

Arguments:

  • receiver: receiver function :type receiver: Callable

disconnect

1
 | disconnect(receiver: Callable) -> bool

Removes the receiver function from the signal.

Arguments:

  • receiver: receiver function :type receiver: Callable

Returns:

flag if receiver was removed :rtype: bool

send

1
 | async send(sender: Type["Model"], **kwargs: Any) -> None

Notifies all receiver functions with given kwargs

Arguments:

  • sender: model that sends the signal :type sender: Type["Model"]
  • kwargs: arguments passed to receivers :type kwargs: Any

SignalEmitter Objects

1
class SignalEmitter()

Emitter that registers the signals in internal dictionary. If signal with given name does not exist it's auto added on access.