Skip to content
Snippets Groups Projects
Commit f6c74748 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

BF: Notifier.notify() could raise an exception if a callback function was GC'd

parent eae17115
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,12 @@ class _Listener:
positional arguments - see :meth:`Notifier.register` for details.
"""
func = self.callback
func = self.callback
# the function may have been GC'd
if func is None:
return False
spec = inspect.signature(func)
posargs = 0
varargs = False
......@@ -377,9 +382,6 @@ class Notifier:
callback = listener.callback
name = listener.name
if listener.expectsArguments: args = (self, topic, value)
else: args = ()
# The callback, or the owner of the
# callback function may have been
# gc'd - remove it if this is the case.
......@@ -387,12 +389,16 @@ class Notifier:
log.debug('Listener %s has been gc\'d - '
'removing from list', name)
self.__listeners[listener.topic].pop(name)
continue
elif not listener.enabled:
if not listener.enabled:
continue
elif listener.runOnIdle: idle.idle(callback, *args)
else: callback( *args)
if listener.expectsArguments: args = (self, topic, value)
else: args = ()
if listener.runOnIdle: idle.idle(callback, *args)
else: callback( *args)
def __getListeners(self, topic):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment