@@ -0,0 +1,1443 @@
+#!/usr/bin/env python%0A#  Author:%0A#  Florian Kaufmann (DE-CIX)%0A%0Aimport json%0Afrom multiprocessing.connection import Listener%0Afrom threading import Thread%0A%0Aimport os%0Aimport sys%0A%0A''' server for participants to handle policy updates '''%0Aclass ParticipantServer(object):%0A%0A    def __init__(self, address, port, logger):%0A        self.logger = logger%0A        self.listener = Listener((address, port), backlog=100)%0A%0A    def start(self, participant_controller):%0A        self.receive = True%0A        self.controller = participant_controller%0A%0A        self.id = self.controller.id%0A        self.logger.debug('participant_server(%25s): start server' %25 self.id)%0A%0A        self.receiver = Thread(target=self.receiver)%0A        self.receiver.start()%0A%0A    def receiver(self):%0A        while self.receive:%0A            conn = self.listener.accept()%0A            self.logger.debug('participant_server(%25s) accepted connection from %25s' %25 (self.id, self.listener.last_accepted))%0A%0A            msg = None%0A            while msg is None:%0A                try:%0A                    msg = conn.recv()%0A                except:%0A                    pass%0A            self.logger.debug('participant_server(%25s): received message' %25 self.id)%0A            self.controller.process_event(json.loads(msg))%0A%0A            conn.close()%0A            self.logger.debug('participant_server(%25s): closed connection' %25 self.id)%0A%0A    def stop(self):%0A        self.receive = False%0A        self.receiver.join(1)%0A

Add participant_server