<commit_before>import socket
from threading import Thread

class PluginManager(Thread):
    def __init__(self, plugin, session_factory):
        Thread.__init__(self)
        self._plugin = plugin
        self._session_factory = session_factory
        self._flag = 0

    def run(self):
        serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        serversocket.bind(('', self._plugin.get_port()))
        serversocket.listen(5)
        while 1:
            clientsocket, address = serversocket.accept()
            if self._flag:
                clientsocket.close()
                break
            else:
                args = clientsocket, address, session_factory()
                Thread(target = self._plugin.run, args = args).start()
        serversocket.close()

    def stop(self):
        self._flag = 1
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect('localhost', self._plugin.get_port())
        sock.close()
<commit_msg>Pass arguments to socket.connect() as tuple<commit_after>import socket
from threading import Thread

class PluginManager(Thread):
    def __init__(self, plugin, session_factory):
        Thread.__init__(self)
        self._plugin = plugin
        self._session_factory = session_factory
        self._flag = 0

    def run(self):
        serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        serversocket.bind(('', self._plugin.get_port()))
        serversocket.listen(5)
        while 1:
            clientsocket, address = serversocket.accept()
            if self._flag:
                clientsocket.close()
                break
            else:
                args = clientsocket, address, session_factory()
                Thread(target = self._plugin.run, args = args).start()
        serversocket.close()

    def stop(self):
        self._flag = 1
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect(('localhost', self._plugin.get_port()))
        sock.close()

{'fraction_non_alphanumeric': 0.10158572844400396, 'fraction_numerical': 0.003964321110009911, 'mean_word_length': 2.2098569157392687, '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': '7271915', 'n_tokens_mistral': 554, 'n_tokens_neox': 539, 'n_words': 117}