# HG changeset patch # User Goffi # Date 1581533045 -3600 # Node ID d0fb79f974663539d1d3c018a696107746e1cc8a # Parent 122075ceaa53112331d961e451694bc5f0238bb9 quick frontends (app): added an "ignore_missing" argument to RemoveListener: normally an error is logged when removeListener is call on a inexisting listener, but sometimes listeners are added only in specific scenarios, and it may be handy to try to delete them without having to explictly check that they have been used. diff -r 122075ceaa53 -r d0fb79f97466 sat_frontends/quick_frontend/quick_app.py --- a/sat_frontends/quick_frontend/quick_app.py Wed Feb 12 19:40:48 2020 +0100 +++ b/sat_frontends/quick_frontend/quick_app.py Wed Feb 12 19:44:05 2020 +0100 @@ -581,18 +581,22 @@ assert type_ in C.LISTENERS self._listeners.setdefault(type_, {})[callback] = profiles_filter - def removeListener(self, type_, callback): + def removeListener(self, type_, callback, ignore_missing=False): """Remove a callback from listeners - @param type_: same as for [addListener] - @param callback: callback to remove + @param type_(str): same as for [addListener] + @param callback(callable): callback to remove + @param ignore_missing(bool): if True, don't log error if the listener doesn't + exist """ assert type_ in C.LISTENERS try: self._listeners[type_].pop(callback) except KeyError: - log.error( - f"Trying to remove an inexisting listener (type = {type_}): {callback}") + if not ignore_missing: + log.error( + f"Trying to remove an inexisting listener (type = {type_}): " + f"{callback}") def callListeners(self, type_, *args, **kwargs): """Call the methods which listen type_ event. If a profiles filter has