import socketserver
import threading

class MyTCPHandler(socketserver.BaseRequestHandler):

    def putter(self, value):
        for queue in self.server.queues:
            queue.put(value)

    def handle(self):
        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).strip()
        print("{0} wrote: {1}".format(self.client_address[0], int(self.data)))
        value = int(self.data)
        self.putter(value = value)
        # just send back the same data, but upper-cased
        self.request.sendall(("ok").encode())

def OpenRecv(queues):
    HOST, PORT = "localhost", 9999
    # Create the server, binding to localhost on port 9999
    server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
    server.queues = queues
    # Activate the server; this will keep running until you
    # interrupt the program with Ctrl-C
    server.serve_forever()

import socketserver
import threading

class MyTCPHandler(socketserver.BaseRequestHandler):

    def putter(self, value):
        for queue in self.server.queues:
            queue.put(value)

    def handle(self):
        # self.request is the TCP socket connected to the client
        self.data = self.request.recv(1024).strip()
        print("{0} wrote: {1}".format(self.client_address[0], int(self.data)))
        value = int(self.data)
        self.putter(value = value)
        # just send back the same data, but upper-cased
        self.request.sendall(("ok").encode())

def OpenRecv(queues):
    HOST, PORT = "localhost", 9999
    # Create the server, binding to localhost on port 9999
    server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
    server.queues = queues
    # Activate the server; this will keep running until you
    # interrupt the program with Ctrl-C
    server.serve_forever()

# self.request is the TCP socket connected to the client # just send back the same data, but upper-cased # Create the server, binding to localhost on port 9999 # Activate the server; this will keep running until you # interrupt the program with Ctrl-C