<commit_before>#!/usr/bin/env python
import errno
import os
import select
import socket
import sys
import threading


def _eintr_retry(func, *args):
    """Restart a system call interrupted by EINTR"""
    while True:
        try:
            return func(*args)
        except (OSError, select.error) as e:
            if e.args[0] != errno.EINTR:
                raise


class ThreadingTCPServer(object):
    """A multi-threaded TCP server"""

    address_family = socket.AF_INET
    socket_type = socket.SOCK_STREAM
    backlog = 5

    def __init__(self, server_address, RequestHandler):
        """
        :param server_address: a pair (host, port)
        :param RequestHandler: request handler class
        """
        self.server_address = server_address
        self.RequestHandler = RequestHandler
        self.socket = socket.socket(self.address_family,
                                    self.socket_type)
        self.socket.bind(self.server_address)
        self.socket.listen(self.backlog)

    def start(self, poll_interval=0.5):
        """
        Start the server

        Use `select` system call (with `poll_interval` argument) to get ready
        sockets without blocking
        """

        while True:
            r, w, e = _eintr_retry(select.select, [self.socket.fileno()],
                                   [], [], poll_interval)
            if self in r:
                self.handle_request()

    def handle_request(self):
        try:
            request, client_address = self.socket.accept()
        except socket.error:
            return
        try:<commit_msg>Fixed if related to select result<commit_after>#!/usr/bin/env python
import errno
import os
import select
import socket
import sys
import threading


def _eintr_retry(func, *args):
    """Restart a system call interrupted by EINTR"""
    while True:
        try:
            return func(*args)
        except (OSError, select.error) as e:
            if e.args[0] != errno.EINTR:
                raise


class ThreadingTCPServer(object):
    """A multi-threaded TCP server"""

    address_family = socket.AF_INET
    socket_type = socket.SOCK_STREAM
    backlog = 5

    def __init__(self, server_address, RequestHandler):
        """
        :param server_address: a pair (host, port)
        :param RequestHandler: request handler class
        """
        self.server_address = server_address
        self.RequestHandler = RequestHandler
        self.socket = socket.socket(self.address_family,
                                    self.socket_type)
        self.socket.bind(self.server_address)
        self.socket.listen(self.backlog)

    def start(self, poll_interval=0.5):
        """
        Start the server

        Use `select` system call (with `poll_interval` argument) to get ready
        sockets without blocking
        """

        while True:
            r, w, e = _eintr_retry(select.select, [self.socket.fileno()],
                                   [], [], poll_interval)
            if self.socket.fileno() in r:
                self.handle_request()

    def handle_request(self):
        try:
            request, client_address = self.socket.accept()
        except socket.error:
            return
        try:
{'fraction_non_alphanumeric': 0.09203211859172329, 'fraction_numerical': 0.0024706609017912293, 'mean_word_length': 1.9770220588235294, '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': '3887163', 'n_tokens_mistral': 908, 'n_tokens_neox': 873, 'n_words': 236}