def run(host, port, handler):
    server = None
    try:
        server = ThreadedTCPServer((host, port), handler)
        server_thread = threading.Thread(target=server.serve_forever)
        server_thread.daemon = True
        server_thread.start()
        log.server_start(server_thread)

        while True:
            # Loop until server shut down
            pass
    except (KeyboardInterrupt, SystemExit):
        utils.clean_up_server(server)
예제 #2
0
def run():
    server = None

    try:
        server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)

        # Start a thread with the server -- that thread will then start one
        # more thread for each request
        server_thread = threading.Thread(target=server.serve_forever)
        # Exit the server thread when the main thread terminates
        server_thread.daemon = True
        server_thread.start()
        log.server_start(server_thread)

        while server.server_alive:
            # Loop until server shut down
            pass
    except (KeyboardInterrupt, SystemExit):
        pass
    finally:
        utils.clean_up_server(server)
예제 #3
0
def run():
    server = None

    try:
        server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)

        # Start a thread with the server -- that thread will then start one
        # more thread for each request
        server_thread = threading.Thread(target=server.serve_forever)
        # Exit the server thread when the main thread terminates
        server_thread.daemon = True
        server_thread.start()
        log.server_start(server_thread)

        while server.server_alive:
            # Loop until server shut down
            pass
    except (KeyboardInterrupt, SystemExit):
        pass
    finally:
        utils.clean_up_server(server)