def _remove_dead_thread_references():
 for thread_reference in set(_thread_references):
  if (thread_reference() is None):
   _thread_references.discard(thread_reference)

def _remove_dead_thread_references ( ) : for thread_reference in set ( _thread_references ) : if ( thread_reference ( ) is None ) : _thread_references . discard ( thread_reference )
remove inactive threads from _thread_references .