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


Python socketserver.ThreadingTCPServer方法代码示例

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


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

示例1: _start_thread

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def _start_thread(self, system):
        self._server = socketserver.ThreadingTCPServer(
            ("", 0),        # Let the OS pick a port for us
            FMSTCPHandler,  # Handler of the requests
            False)
        self._server.allow_reuse_address = True
        self._server.server_bind()
        self._server.server_activate()
        self._server.terminate = False
        self._server.system = system
        self._server.sleep_in_seconds = self._config["sleep"]
        if "min_event_per_burst" in self._config:
            self._server.min_event_per_burst = \
                int(self._config["min_event_per_burst"])
        else:
            self._server.min_event_per_burst = 500

        self._server_thread = threading.Thread(target=self._serve_forever)
        self._server_thread.start()
        port_used = self._server.socket.getsockname()[1]
        return port_used 
开发者ID:openstack,项目名称:monasca-analytics,代码行数:23,代码来源:base.py

示例2: _configure_server

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def _configure_server(self):
        """Creates and configures the Server object

        The server object is configured according to
        the configuration of this source module
        """
        self._server = socketserver.ThreadingTCPServer(
            (self._config["params"]["host"],
             self._config["params"]["port"]),
            MonanasTCPHandler, False)
        self._server.generate = getattr(
            self, "_generate_" +
            self._config["params"]["model"]["name"])
        # self._server.validate = getattr(
        #    source_model, self._config["validate"])
        self._server.allow_reuse_address = True
        self._server.server_bind()
        self._server.server_activate()
        self._server.terminate = False
        self._server.generate_alerts_per_second =\
            self._config["params"]["alerts_per_burst"]
        self._server.generate_idle_time_between_bursts =\
            self._config["params"]["idle_time_between_bursts"]
        self._server_thread = th.Thread(target=self._server.serve_forever)
        self._is_server_running = False 
开发者ID:openstack,项目名称:monasca-analytics,代码行数:27,代码来源:randoms.py

示例3: create_dstream

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def create_dstream(self, ssc):
        """Initiates the system in a TCP server, and creates the dstream object

        The _dstream object is created before this source is bound
        to the consumers. It uses a socketTextStream, to read data from
        the ThreadingTCPServer.

        :type ssc: pyspark.streaming.StreamingContext
        :param ssc: Spark Streaming Context that provides the data input
        """
        system = LeafNodes(self._create_system())
        port = self._start_thread(system)
        return ssc.socketTextStream(
            "localhost",
            port) 
开发者ID:openstack,项目名称:monasca-analytics,代码行数:17,代码来源:base.py

示例4: create_dstream

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def create_dstream(self, ssc):
        """Dstream object creation

        The _dstream object is created before this source is bound
        to the consumers. It uses a socketTextStream, to read data from
        the ThreadingTCPServer.

        :type ssc: pyspark.streaming.StreamingContext
        :param ssc: Spark Streaming Context
        """
        self._start_server()
        self._dstream = ssc.socketTextStream(
            self._config["params"]["host"],
            self._config["params"]["port"]) 
开发者ID:openstack,项目名称:monasca-analytics,代码行数:16,代码来源:randoms.py

示例5: __init__

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def __init__(self, host='', port=16838, *args, **kwargs):
        socketserver.ThreadingTCPServer.__init__(self, (host, port), ThreadedTCPRequestHandler)
        self.requests = {}
        self.server_thread = threading.Thread(target=self.serve_forever)
        self.server_thread.setDaemon(True)
        self.server_thread.start()
        self.onConnected = None
        self.onDisconnected = None
        self.onData = None 
开发者ID:devcartel,项目名称:pymt5,代码行数:11,代码来源:pymt5.py

示例6: __init__

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def __init__(self, *args, **kwargs):
        super(SockListener, self).__init__(*args, **kwargs)
        # inject service_handler
        SockBoltHandler.service_handler = self.handler
        self.server = ThreadingTCPServer(self.address, SockBoltHandler) 
开发者ID:sofastack,项目名称:sofa-bolt-python,代码行数:7,代码来源:sock_listener.py

示例7: start_server

# 需要导入模块: from six.moves import socketserver [as 别名]
# 或者: from six.moves.socketserver import ThreadingTCPServer [as 别名]
def start_server(sync):
        # type: (bool) -> int
        """Start the TCP server."""
        # N.B. port = 0 chooses any arbitrary open one
        CoqtailHandler.sync = sync
        CoqtailServer.serv = ThreadingTCPServer(("localhost", 0), CoqtailHandler)
        CoqtailServer.serv.daemon_threads = True
        _, port = CoqtailServer.serv.server_address

        serv_thread = threading.Thread(target=CoqtailServer.serv.serve_forever)
        serv_thread.daemon = True
        serv_thread.start()

        return port 
开发者ID:whonore,项目名称:Coqtail,代码行数:16,代码来源:coqtail.py


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