<commit_before>from tests import LimitedTestCase, main, skip_with_pyevent, skip_if_no_itimer
import time
import eventlet
from eventlet import hubs
from eventlet.green import socket

DELAY = 0.001
def noop():
    pass

class TestTimerCleanup(LimitedTestCase):
    @skip_with_pyevent
    def test_cancel_immediate(self):
        hub = hubs.get_hub()
        stimers = hub.get_timers_count()
        scanceled = hub.timers_canceled
        for i in xrange(2000):
            t = hubs.get_hub().schedule_call_global(60, noop)
            t.cancel()
            self.assert_less_than_equal(hub.timers_canceled - scanceled,
                                  hub.get_timers_count() - stimers + 1)
        # there should be fewer than 1000 new timers and canceled
        self.assert_less_than_equal(hub.get_timers_count(), 1000 + stimers)
        self.assert_less_than_equal(hub.timers_canceled, 1000)


    @skip_with_pyevent
    def test_cancel_accumulated(self):
        hub = hubs.get_hub()
        stimers = hub.get_timers_count()
        scanceled = hub.timers_canceled
        for i in xrange(2000):
            t = hubs.get_hub().schedule_call_global(60, noop)
            eventlet.sleep()
            self.assert_less_than_equal(hub.timers_canceled - scanceled,
                                  hub.get_timers_count() - stimers + 1)
            t.cancel()
            self.assert_less_than_equal(hub.timers_canceled - scanceled,
                                  hub.get_timers_count() - stimers + 1)
        # there should be fewer than 1000 new timers and canceled
        self.assert_less_than_equal(hub.get_timers_count(), 1000 + stimers)
        self.assert_less_than_equal(hub.timers_canceled, 1000)<commit_msg>Increasing timeout for that slow Darwin box<commit_after>from tests import LimitedTestCase, main, skip_with_pyevent, skip_if_no_itimer
import time
import eventlet
from eventlet import hubs
from eventlet.green import socket

DELAY = 0.001
def noop():
    pass

class TestTimerCleanup(LimitedTestCase):
    TEST_TIMEOUT = 2
    @skip_with_pyevent
    def test_cancel_immediate(self):
        hub = hubs.get_hub()
        stimers = hub.get_timers_count()
        scanceled = hub.timers_canceled
        for i in xrange(2000):
            t = hubs.get_hub().schedule_call_global(60, noop)
            t.cancel()
            self.assert_less_than_equal(hub.timers_canceled - scanceled,
                                  hub.get_timers_count() - stimers + 1)
        # there should be fewer than 1000 new timers and canceled
        self.assert_less_than_equal(hub.get_timers_count(), 1000 + stimers)
        self.assert_less_than_equal(hub.timers_canceled, 1000)


    @skip_with_pyevent
    def test_cancel_accumulated(self):
        hub = hubs.get_hub()
        stimers = hub.get_timers_count()
        scanceled = hub.timers_canceled
        for i in xrange(2000):
            t = hubs.get_hub().schedule_call_global(60, noop)
            eventlet.sleep()
            self.assert_less_than_equal(hub.timers_canceled - scanceled,
                                  hub.get_timers_count() - stimers + 1)
            t.cancel()
            self.assert_less_than_equal(hub.timers_canceled - scanceled,
                                  hub.get_timers_count() - stimers + 1)
        # there should be fewer than 1000 new timers and canceled
        self.assert_less_than_equal(hub.get_timers_count(), 1000 + stimers)
        self.assert_less_than_equal(hub.timers_canceled, 1000)
{'fraction_non_alphanumeric': 0.07762818676596964, 'fraction_numerical': 0.02492122600973933, 'mean_word_length': 2.450592885375494, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2050101', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1092, 'n_words': 219}