<commit_before># coding: utf-8
from twisted.internet import defer
from txamqp.delegate import Delegate

class Closed(Exception):
    pass

class TwistedEvent(object):
    def __init__(self):
        self.deferred = defer.Deferred()
        self.alreadyCalled = False

    def set(self):
        self.deferred.callback(True)

    def wait(self):
        return self.deferred

    def reset(self):
        deferred, self.deferred = self.deferred, defer.Deferred()
        deferred.callback(True)

class TwistedDelegate(Delegate):

    def connection_start(self, ch, msg):
        ch.connection_start_ok(mechanism=self.client.mechanism,
                               response=self.client.response,
                               locale=self.client.locale)

    def connection_tune(self, ch, msg):
        self.client.MAX_LENGTH = msg.frame_max
        ch.connection_tune_ok(*msg.fields)
        self.client.started.set()

    @defer.inlineCallbacks
    def basic_deliver(self, ch, msg):
        (yield self.client.queue(msg.consumer_tag)).put(msg)

    def channel_close(self, ch, msg):
        ch.close(msg)

    def connection_close(self, ch, msg):
        self.client.close(msg)

    def close(self, reason):
        self.client.closed = True
        self.client.started.reset()
<commit_msg>use reset instead of set. Fixes a problem in test_close_queue<commit_after># coding: utf-8
from twisted.internet import defer
from txamqp.delegate import Delegate

class Closed(Exception):
    pass

class TwistedEvent(object):
    def __init__(self):
        self.deferred = defer.Deferred()
        self.alreadyCalled = False

    def set(self):
        self.deferred.callback(True)

    def wait(self):
        return self.deferred

    def reset(self):
        deferred, self.deferred = self.deferred, defer.Deferred()
        deferred.callback(True)

class TwistedDelegate(Delegate):

    def connection_start(self, ch, msg):
        ch.connection_start_ok(mechanism=self.client.mechanism,
                               response=self.client.response,
                               locale=self.client.locale)

    def connection_tune(self, ch, msg):
        self.client.MAX_LENGTH = msg.frame_max
        ch.connection_tune_ok(*msg.fields)
        self.client.started.reset()

    @defer.inlineCallbacks
    def basic_deliver(self, ch, msg):
        (yield self.client.queue(msg.consumer_tag)).put(msg)

    def channel_close(self, ch, msg):
        ch.close(msg)

    def connection_close(self, ch, msg):
        self.client.close(msg)

    def close(self, reason):
        self.client.closed = True
        self.client.started.reset()

{'fraction_non_alphanumeric': 0.10364464692482915, 'fraction_numerical': 0.0007593014426727411, 'mean_word_length': 2.5656292286874156, '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': '879196', 'n_tokens_mistral': 818, 'n_tokens_neox': 783, 'n_words': 161}