Python socketserver.ThreadingUnixStreamServer() Examples

The following are 6 code examples of socketserver.ThreadingUnixStreamServer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module socketserver , or try the search function .
Example #1
Source File: test_socketserver.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_ThreadingUnixStreamServer(self):
        self.run_server(socketserver.ThreadingUnixStreamServer,
                        socketserver.StreamRequestHandler,
                        self.stream_examine) 
Example #2
Source File: test_socketserver.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_ThreadingUnixStreamServer(self):
        self.run_server(socketserver.ThreadingUnixStreamServer,
                        socketserver.StreamRequestHandler,
                        self.stream_examine) 
Example #3
Source File: test_socketserver.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_ThreadingUnixStreamServer(self):
        self.run_server(socketserver.ThreadingUnixStreamServer,
                        socketserver.StreamRequestHandler,
                        self.stream_examine) 
Example #4
Source File: server.py    From PeekabooAV with GNU General Public License v3.0 5 votes vote down vote up
def shutdown(self):
        """ Shut down the server. In our case, notify requests which are
        currently being handled to shut down as well and then wait until all
        are finished. """
        self.__shutdown_requested = True
        for thread in self.__request_triggers:
            # wake up the thread so it can see that we're shutting down
            self.__request_triggers[thread].set()

        socketserver.ThreadingUnixStreamServer.shutdown(self) 
Example #5
Source File: test_socketserver.py    From android_universal with MIT License 5 votes vote down vote up
def test_ThreadingUnixStreamServer(self):
        self.run_server(socketserver.ThreadingUnixStreamServer,
                        socketserver.StreamRequestHandler,
                        self.stream_examine) 
Example #6
Source File: server.py    From bc18-scaffold with MIT License 4 votes vote down vote up
def start_server(sock_file: str, game: Game, dockers, use_docker=True) -> socketserver.BaseServer:
    '''
    Start a socket server for the players to connect to
    Args:
        sock_file: This is a string name of the file that will be used for
                    as UnixStream

        game: The game information that is being run

        use_docker bool: whether to use docker or not

    Return:
        server_thread: The connection so it can be closed by parent functions at
                        the appropriate time
    '''

    # Create handler for mangaing each connections to server
    receive_handler = create_receive_handler(game, dockers, use_docker, True)

    if isinstance(sock_file, tuple):
        # tcp port
        server = socketserver.ThreadingTCPServer(sock_file, receive_handler)
    else:
        server = socketserver.ThreadingUnixStreamServer(sock_file, receive_handler)

    def wait_for_connections():
        time.sleep(BUILD_TIMEOUT)
        for player in game.players:
            if not player['built_successfully']:
                print('Player failed to connect to manager after',BUILD_TIMEOUT,'seconds:', player['player'])
                if bc.Team.Red == player['player'].team:
                    game.winner = 'player2'
                else:
                    game.winner = 'player1'
                game.disconnected = True
                game.game_over = True

    server_thread = threading.Thread(target=server.serve_forever, daemon=True)
    logging.info("Server Started at %s", sock_file)
    server_thread.start()
    waiter_thread = threading.Thread(target=wait_for_connections, daemon=True)
    waiter_thread.start()

    return server