Remove a permanent callback

5 views
Skip to first unread message

Chris Piekarski

unread,
Sep 16, 2010, 12:27:58 AM9/16/10
to python-callbacks
Very cool piece of code. I was using it for a project and needed to
be able to remove a previously registered "permanent" callback at
anytime. Just thought I'd share in case anyone else need something
similar.

def ClearCallback(scope, name, callback):
try:
callback_map = _GetCallbackMap(scope)
callback_queue = callback_map[name]
for i in callback_queue.queue:
if callback is i[2].callback:
callback_queue.queue.remove(i)
if(len(callback_queue.queue) is 0):
ClearCallbacks(scope, name)
except KeyError:
pass
Reply all
Reply to author
Forward
0 new messages