RemovableEventHandle#
- class ignite.engine.events.RemovableEventHandle(event_name, handler, engine)[source]#
A weakref handle to remove a registered event.
A handle that may be used to remove a registered event handler via the remove method, with-statement, or context manager protocol. Returned from
add_event_handler()
.- Parameters
event_name (Union[CallableEventWithFilter, Enum, EventsList, Events]) – Registered event name.
handler (Callable) – Registered event handler, stored as weakref.
engine (Engine) – Target engine, stored as weakref.
Example usage:
engine = Engine() def print_epoch(engine): print(f"Epoch: {engine.state.epoch}") with engine.add_event_handler(Events.EPOCH_COMPLETED, print_epoch): # print_epoch handler registered for a single run engine.run(data) # print_epoch handler is now unregistered
Methods
Remove handler from engine.