counter_callback¶
Counter Callback implementation.
Callback that count events and calls the passed fn evert event_freq.
Classes
CounterCallback |
Count events of a specific type. |
-
class
ashpy.callbacks.counter_callback.
CounterCallback
(event, fn, name, event_freq=1)[source]¶ Bases:
ashpy.callbacks.callback.Callback
Count events of a specific type. Calls fn passing the context every event_freq.
Useful for logging or for measuring performance. If you want to implement a callback defining a certain behaviour every n_events you can just inherit from CounterCallback.
-
__init__
(event, fn, name, event_freq=1)[source]¶ Initialize the CounterCallback.
Parameters: Raises: ValueError
– if event_freq is not valid.Return type: None
-
on_event
(event, context)[source]¶ Count events and calls fn.
Parameters: - event (
ashpy.callbacks.events.Event
) – current event. - context (
ashpy.contexts.context.Context
) – current context.
- event (
-