Register a handler with an event. :type event_name: str :param event_name: The name of the event. :type handler: callable :param handler: The callback to invoke when the event is emitted. This object must be callable, and must accept ``**kwa
(
self, event_name, handler, unique_id=None, unique_id_uses_count=False
)
| 663 | log.addHandler(ch) |
| 664 | |
| 665 | def register( |
| 666 | self, event_name, handler, unique_id=None, unique_id_uses_count=False |
| 667 | ): |
| 668 | """Register a handler with an event. |
| 669 | |
| 670 | :type event_name: str |
| 671 | :param event_name: The name of the event. |
| 672 | |
| 673 | :type handler: callable |
| 674 | :param handler: The callback to invoke when the event |
| 675 | is emitted. This object must be callable, and must |
| 676 | accept ``**kwargs``. If either of these preconditions are |
| 677 | not met, a ``ValueError`` will be raised. |
| 678 | |
| 679 | :type unique_id: str |
| 680 | :param unique_id: An optional identifier to associate with the |
| 681 | registration. A unique_id can only be used once for |
| 682 | the entire session registration (unless it is unregistered). |
| 683 | This can be used to prevent an event handler from being |
| 684 | registered twice. |
| 685 | |
| 686 | :param unique_id_uses_count: boolean |
| 687 | :param unique_id_uses_count: Specifies if the event should maintain |
| 688 | a count when a ``unique_id`` is registered and unregisted. The |
| 689 | event can only be completely unregistered once every register call |
| 690 | using the unique id has been matched by an ``unregister`` call. |
| 691 | If ``unique_id`` is specified, subsequent ``register`` |
| 692 | calls must use the same value for ``unique_id_uses_count`` |
| 693 | as the ``register`` call that first registered the event. |
| 694 | |
| 695 | :raises ValueError: If the call to ``register`` uses ``unique_id`` |
| 696 | but the value for ``unique_id_uses_count`` differs from the |
| 697 | ``unique_id_uses_count`` value declared by the very first |
| 698 | ``register`` call for that ``unique_id``. |
| 699 | """ |
| 700 | self._events.register( |
| 701 | event_name, |
| 702 | handler, |
| 703 | unique_id, |
| 704 | unique_id_uses_count=unique_id_uses_count, |
| 705 | ) |
| 706 | |
| 707 | def unregister( |
| 708 | self, |
no outgoing calls