<commit_before>"""Run pika on the Tornado IOLoop"""
from tornado import ioloop
import time

from pika.adapters import base_connection


class TornadoConnection(base_connection.BaseConnection):
    """The TornadoConnection runs on the Tornado IOLoop. If you're running the
    connection in a web app, make sure you set stop_ioloop_on_close to False,
    which is the default behavior for this adapter, otherwise the web app
    will stop taking requests.

    """
    def __init__(self, parameters=None,
                 on_open_callback=None,
                 stop_ioloop_on_close=False):
        super(TornadoConnection, self).__init__(parameters, on_open_callback,
                                                stop_ioloop_on_close)

    def _adapter_connect(self):
        """Connect to the RabbitMQ broker"""
        super(TornadoConnection, self)._adapter_connect()
        self.ioloop = ioloop.IOLoop.instance()
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,
                                self.event_state)
        self._on_connected()

    def _adapter_disconnect(self):
        """Disconnect from the RabbitMQ broker"""
        super(TornadoConnection, self)._adapter_disconnect()
        self.ioloop.remove_handler(self.socket.fileno())<commit_msg>Add a custom IO loop override back in to address ticket #181<commit_after>"""Run pika on the Tornado IOLoop"""
from tornado import ioloop
import time

from pika.adapters import base_connection


class TornadoConnection(base_connection.BaseConnection):
    """The TornadoConnection runs on the Tornado IOLoop. If you're running the
    connection in a web app, make sure you set stop_ioloop_on_close to False,
    which is the default behavior for this adapter, otherwise the web app
    will stop taking requests.

    """
    def __init__(self, parameters=None,
                 on_open_callback=None,
                 stop_ioloop_on_close=False,
                 custom_ioloop=None):
        self._ioloop = custom_ioloop or ioloop.IOLoop.instance()
        super(TornadoConnection, self).__init__(parameters, on_open_callback,
                                                stop_ioloop_on_close)

    def _adapter_connect(self):
        """Connect to the RabbitMQ broker"""
        super(TornadoConnection, self)._adapter_connect()
        self.ioloop = self._ioloop
        self.ioloop.add_handler(self.socket.fileno(),
                                self._handle_events,
                                self.event_state)
        self._on_connected()

    def _adapter_disconnect(self):
        """Disconnect from the RabbitMQ broker"""
        super(TornadoConnection, self)._adapter_disconnect()
        self.ioloop.remove_handler(self.socket.fileno())
{'fraction_non_alphanumeric': 0.07551240560949299, 'fraction_numerical': 0.0010787486515641855, 'mean_word_length': 2.553001277139208, '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': '2537980', 'n_tokens_mistral': 782, 'n_tokens_neox': 737, 'n_words': 197}