<commit_before>#!/usr/bin/env python
#  Author:
#  <NAME> (DE-CIX)

import json
from multiprocessing.connection import Listener
from threading import Thread

import os
import sys

''' Server for Participants to handle Policy Updates '''
class ParticipantServer(object):

    def __init__(self, participant_controller, address, port, logger):
        self.logger = logger
        self.logger.info('participant_server(%s): start server' % participant_controller.id)

        self.controller = participant_controller
        self.listener = Listener((address, port), backlog=100)

    def start(self):
        self.receive = True
        self.receiver = Thread(target=self.receiver)
        self.receiver.start()

    def receiver(self):
        while self.receive:
            conn = self.listener.accept()
            self.logger.info('participant_server(%s) accepted connection from %s' % (participant_controller.id, self.listener.last_accepted))

            msg = None
            while msg is None:
                try:
                    msg = conn.recv()
                except:
                    pass
            self.logger.debug('participant_server(%s): received message' % participant_controller.id)
            self.controller.process_event(json.loads(msg))

            conn.close()
            self.logger.debug('participant_server(%s): closed connection' % participant_controller.id)

    def stop(self):
        self.receive = False
        self.receiver.join(1)<commit_msg>fix syntax error in participant server<commit_after>#!/usr/bin/env python
#  Author:
#  <NAME> (DE-CIX)

import json
from multiprocessing.connection import Listener
from threading import Thread

import os
import sys

''' Server for Participants to handle Policy Updates '''
class ParticipantServer(object):

    def __init__(self, participant_controller, address, port, logger):
        self.logger = logger
        self.controller = participant_controller

        self.logger.debug('participant_server(%s): start server' % self.controller.id)
        self.listener = Listener((address, port), backlog=100)

    def start(self):
        self.receive = True
        self.receiver = Thread(target=self.receiver)
        self.receiver.start()

    def receiver(self):
        while self.receive:
            conn = self.listener.accept()
            self.logger.debug('participant_server(%s) accepted connection from %s' % (self.controller.id, self.listener.last_accepted))

            msg = None
            while msg is None:
                try:
                    msg = conn.recv()
                except:
                    pass
            self.logger.debug('participant_server(%s): received message' % pself.controller.id)
            self.controller.process_event(json.loads(msg))

            conn.close()
            self.logger.debug('participant_server(%s): closed connection' % pself.controller.id)

    def stop(self):
        self.receive = False
        self.receiver.join(1)
{'fraction_non_alphanumeric': 0.10258129399932954, 'fraction_numerical': 0.0026818638954073082, 'mean_word_length': 2.4941451990632317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3800185', 'n_tokens_mistral': 828, 'n_tokens_neox': 783, 'n_words': 188}