events: add function to remove event handlers

Event handlers for remote mgmt API will be registered dynamically, so
allow to unregister them.

QubesOS/qubes-issues#2622
This commit is contained in:
Marek Marczykowski-Górecki 2017-04-10 00:50:18 +02:00
parent 68c8d219c9
commit ee967c1e72
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -115,6 +115,17 @@ class Emitter(object, metaclass=EmitterMeta):
# pylint: disable=no-member
cls.__handlers__[event].add(func)
@classmethod
def remove_handler(cls, event, func):
'''Remove event handler from subject's class.
:param str event: event identificator
:param collections.Callable handler: handler callable
'''
# pylint: disable=no-member
cls.__handlers__[event].remove(func)
def _fire_event_in_order(self, order, event, kwargs):
'''Fire event for classes in given order.