<commit_before>import copy 
class Observable(object):
    """
        A dirt simple observable that can collect multiple
        deferreds and discharge them.
        
        On emit, all deferreds have their callback's fired
        and then the deferred is popped out, making it the
        responsibility of the deferred's origin to reapply
    """
    
    def __init__(self):
        self.stack = []
    
    def observe(self, deferred):
        self.stack.append(deferred)
        
    def emit(self, *args, **kwargs):
        """
            To prevent the handler for a deferred putting the system
            into a death spiral, copy the stack, then assign a new list
            instance to self.stack
        """
        oldStack = copy.deepcopy(self.stack)
        self.stack = []
        while len(oldStack):
            #@todo can't remember if Twisted...deferred handles exceptions from
            #it's handlers
            deferred = oldstack.pop()
            deferred.callback(*args, **kwargs)
        <commit_msg>Fixed spelling mistake and used a light copy vs. deepcopy which was the source of the infinite recursion issue<commit_after>import copy 
class Observable(object):
    """
        A dirt simple observable that can collect multiple
        deferreds and discharge them.
        
        On emit, all deferreds have their callback's fired
        and then the deferred is popped out, making it the
        responsibility of the deferred's origin to reapply
    """
    
    def __init__(self):
        self.stack = []
    
    def observe(self, deferred):
        self.stack.append(deferred)
        
    def emit(self, *args, **kwargs):
        """
            To prevent the handler for a deferred putting the system
            into a death spiral, copy the stack, then assign a new list
            instance to self.stack
        """
        oldStack = self.stack[:]
        self.stack = []
        while len(oldStack):
            #@todo can't remember if Twisted...deferred handles exceptions from
            #it's handlers
            deferred = oldStack.pop()
            deferred.callback(*args, **kwargs)
        
{'fraction_non_alphanumeric': 0.0746407046824293, 'fraction_numerical': 0.0, 'mean_word_length': 1.9521203830369358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4638451', 'n_tokens_mistral': 551, 'n_tokens_neox': 524, 'n_words': 210}