<commit_before>
import tornado_pyuv
tornado_pyuv.install()

from tornado import ioloop
from tornado import netutil


class EchoServer(netutil.TCPServer):

    def handle_stream(self, stream, address):
        self._stream = stream
        self._read_line()

    def _read_line(self):
        self._stream.read_until('\n', self._handle_read)

    def _handle_read(self, data):
        self._stream.write(data)
        self._read_line()


if __name__ == '__main__':
    server = EchoServer()
    server.listen(8889)
    ioloop.IOLoop.instance().start()
<commit_msg>Allow echo-server example to be killed with Ctrl+C<commit_after>
import tornado_pyuv
tornado_pyuv.install()

import signal

from tornado.ioloop import IOLoop
from tornado.netutil import TCPServer


def handle_signal(sig, frame):
    IOLoop.instance().add_callback(IOLoop.instance().stop)


class EchoServer(TCPServer):

    def handle_stream(self, stream, address):
        self._stream = stream
        self._read_line()

    def _read_line(self):
        self._stream.read_until('\n', self._handle_read)

    def _handle_read(self, data):
        self._stream.write(data)
        self._read_line()


if __name__ == '__main__':
    signal.signal(signal.SIGINT, handle_signal)
    signal.signal(signal.SIGTERM, handle_signal)
    server = EchoServer()
    server.listen(8889)
    IOLoop.instance().start()

{'fraction_non_alphanumeric': 0.10810810810810811, 'fraction_numerical': 0.005843681519357195, 'mean_word_length': 3.6283783783783785, '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': '3707124', 'n_tokens_mistral': 462, 'n_tokens_neox': 438, 'n_words': 91}