def _addHandlerRef(handler):
 _acquireLock()
 try:
  _handlerList.append(weakref.ref(handler, _removeHandlerRef))
 finally:
  _releaseLock()

def _addHandlerRef ( handler ) : _acquireLock ( ) try : _handlerList . append ( weakref . ref ( handler , _removeHandlerRef ) ) finally : _releaseLock ( )
add a handler to the internal cleanup list using a weak reference .