<commit_before># ***** BEGIN LICENSE BLOCK *****
#
# For copyright and licensing please refer to COPYING.
#
# ***** END LICENSE BLOCK *****
try:
    from tornado import ioloop
    IOLoop = ioloop.IOLoop
except ImportError:
    IOLoop = None

from warnings import warn

from pika.adapters.base_connection import BaseConnection

# Redefine our constants with Tornado's
if IOLoop:
    ERROR = ioloop.IOLoop.ERROR
    READ = ioloop.IOLoop.READ
    WRITE = ioloop.IOLoop.WRITE


class TornadoConnection(BaseConnection):

    def __init__(self, parameters=None,
                 on_open_callback=None,
                 reconnection_strategy=None):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)

    def _adapter_connect(self):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self)

        # Setup our ioloop
        self.ioloop = IOLoop.instance()

        # Setup a periodic callbacks
        _pc = ioloop.PeriodicCallback(self._manage_event_state,
                                      0.25,
                                      self.ioloop)
        _pc.start()

        # Add the ioloop handler for the event state
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,<commit_msg>Tornado callback interval was .25ms.  Changing to (desired) 25ms, and adding option to set your own interval<commit_after># ***** BEGIN LICENSE BLOCK *****
#
# For copyright and licensing please refer to COPYING.
#
# ***** END LICENSE BLOCK *****
try:
    from tornado import ioloop
    IOLoop = ioloop.IOLoop
except ImportError:
    IOLoop = None

from warnings import warn

from pika.adapters.base_connection import BaseConnection

# Redefine our constants with Tornado's
if IOLoop:
    ERROR = ioloop.IOLoop.ERROR
    READ = ioloop.IOLoop.READ
    WRITE = ioloop.IOLoop.WRITE


class TornadoConnection(BaseConnection):

    def __init__(self, parameters=None,
                 on_open_callback=None,
                 reconnection_strategy=None,
                 callback_interval=250):

        # Validate we have Tornado installed
        if not IOLoop:
            raise ImportError("Tornado not installed")

        self.callback_interval = callback_interval

        BaseConnection.__init__(self, parameters, on_open_callback,
                                reconnection_strategy)

    def _adapter_connect(self):
        """
        Connect to the given host and port
        """
        BaseConnection._adapter_connect(self)

        # Setup our ioloop
        self.ioloop = IOLoop.instance()

        # Setup a periodic callbacks
        _pc = ioloop.PeriodicCallback(self._manage_event_state,
                                      self.callback_interval,
                                      self.ioloop)
        _pc.start()

        # Add the ioloop handler for the event state
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,
{'fraction_non_alphanumeric': 0.0742713882795362, 'fraction_numerical': 0.0031338138514572234, 'mean_word_length': 2.090029041626331, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '652402', 'n_tokens_mistral': 919, 'n_tokens_neox': 859, 'n_words': 226}