当前位置: 首页>>代码示例>>Python>>正文


Python socketserver.ThreadingUnixStreamServer方法代码示例

本文整理汇总了Python中socketserver.ThreadingUnixStreamServer方法的典型用法代码示例。如果您正苦于以下问题:Python socketserver.ThreadingUnixStreamServer方法的具体用法?Python socketserver.ThreadingUnixStreamServer怎么用?Python socketserver.ThreadingUnixStreamServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socketserver的用法示例。


在下文中一共展示了socketserver.ThreadingUnixStreamServer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ThreadingUnixStreamServer

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import ThreadingUnixStreamServer [as 别名]
def test_ThreadingUnixStreamServer(self):
        self.run_server(socketserver.ThreadingUnixStreamServer,
                        socketserver.StreamRequestHandler,
                        self.stream_examine) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_socketserver.py

示例2: shutdown

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import ThreadingUnixStreamServer [as 别名]
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) 
开发者ID:scVENUS,项目名称:PeekabooAV,代码行数:12,代码来源:server.py

示例3: start_server

# 需要导入模块: import socketserver [as 别名]
# 或者: from socketserver import ThreadingUnixStreamServer [as 别名]
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 
开发者ID:battlecode,项目名称:bc18-scaffold,代码行数:46,代码来源:server.py


注:本文中的socketserver.ThreadingUnixStreamServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。