Toloka documentation

register_callback

toloka.streaming.observer.AssignmentsObserver.register_callback | Source code

register_callback(
    self,
    callback: Union[Callable[[List[AssignmentEvent]], None], Callable[[List[AssignmentEvent]], Awaitable[None]]],
    event_type: AssignmentEvent.Type
)

Register given callable for given event type.

Callback will be called multiple times if it has been registered for multiple event types.

Parameters Description

Parameters Type Description
callback Union[Callable[[List[AssignmentEvent]], None], Callable[[List[AssignmentEvent]], Awaitable[None]]]

Sync or async callable that pass List[AssignmentEvent] of desired event type.

event_type AssignmentEvent.Type

Selected event type.

  • Returns:

    The same callable passed as callback.

  • Return type:

    Union[Callable[[List[AssignmentEvent]], None], Callable[[List[AssignmentEvent]], Awaitable[None]]]