Fix Handler unregister (#1050)

Add checking for handler_obj.handler
This commit is contained in:
Butvin Mihail 2022-11-06 04:55:23 +03:00 committed by GitHub
parent 707988bf03
commit 19e97de8cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,11 +74,12 @@ class Handler:
:param handler: callback :param handler: callback
:return: :return:
""" """
for handler_obj in self.handlers: for handler_obj in self.handlers:
registered = handler_obj.handler if handler == handler_obj or handler == handler_obj.handler:
if handler in self.handlers: self.handlers.remove(handler_obj)
self.handlers.remove(handler)
return True return True
raise ValueError('This handler is not registered!') raise ValueError('This handler is not registered!')
async def notify(self, *args): async def notify(self, *args):