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


Python SocketServer.StreamRequestHandler方法代码示例

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


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

示例1: test_shutdown

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_shutdown(self):
        # Issue #2302: shutdown() should always succeed in making an
        # other thread leave serve_forever().
        class MyServer(SocketServer.TCPServer):
            pass

        class MyHandler(SocketServer.StreamRequestHandler):
            pass

        threads = []
        for i in range(20):
            s = MyServer((HOST, 0), MyHandler)
            t = threading.Thread(
                name='MyServer serving',
                target=s.serve_forever,
                kwargs={'poll_interval':0.01})
            t.daemon = True  # In case this function raises.
            threads.append((t, s))
        for t, s in threads:
            t.start()
            s.shutdown()
        for t, s in threads:
            t.join()
            close_server(s) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_socketserver.py

示例2: test_shutdown_request_called_if_verify_request_false

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_shutdown_request_called_if_verify_request_false(self):
        # Issue #26309: BaseServer should call shutdown_request even if
        # verify_request is False

        class MyServer(SocketServer.TCPServer):
            def verify_request(self, request, client_address):
                return False

            shutdown_called = 0
            def shutdown_request(self, request):
                self.shutdown_called += 1
                SocketServer.TCPServer.shutdown_request(self, request)

        server = MyServer((HOST, 0), SocketServer.StreamRequestHandler)
        s = socket.socket(server.address_family, socket.SOCK_STREAM)
        s.connect(server.server_address)
        s.close()
        server.handle_request()
        self.assertEqual(server.shutdown_called, 1)
        close_server(server) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_socketserver.py

示例3: test_shutdown

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_shutdown(self):
        # Issue #2302: shutdown() should always succeed in making an
        # other thread leave serve_forever().
        class MyServer(SocketServer.TCPServer):
            pass

        class MyHandler(SocketServer.StreamRequestHandler):
            pass

        threads = []
        for i in range(20):
            s = MyServer((HOST, 0), MyHandler)
            t = threading.Thread(
                name='MyServer serving',
                target=s.serve_forever,
                kwargs={'poll_interval':0.01})
            t.daemon = True  # In case this function raises.
            threads.append((t, s))
        for t, s in threads:
            t.start()
            s.shutdown()
        for t, s in threads:
            t.join() 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:25,代码来源:test_socketserver.py

示例4: setup

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def setup(self):
        """Override SocketServer.StreamRequestHandler.setup to wrap rfile
        with MemorizingFile.

        This method will be called by BaseRequestHandler's constructor
        before calling BaseHTTPRequestHandler.handle.
        BaseHTTPRequestHandler.handle will call
        BaseHTTPRequestHandler.handle_one_request and it will call
        WebSocketRequestHandler.parse_request.
        """

        # Call superclass's setup to prepare rfile, wfile, etc. See setup
        # definition on the root class SocketServer.StreamRequestHandler to
        # understand what this does.
        CGIHTTPServer.CGIHTTPRequestHandler.setup(self)

        self.rfile = memorizingfile.MemorizingFile(
            self.rfile,
            max_memorized_lines=_MAX_MEMORIZED_LINES) 
开发者ID:googlearchive,项目名称:pywebsocket,代码行数:21,代码来源:standalone.py

示例5: test_TCPServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_TCPServer(self):
        self.run_server(SocketServer.TCPServer,
                        SocketServer.StreamRequestHandler,
                        self.stream_examine) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_socketserver.py

示例6: test_ThreadingTCPServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_ThreadingTCPServer(self):
        self.run_server(SocketServer.ThreadingTCPServer,
                        SocketServer.StreamRequestHandler,
                        self.stream_examine) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_socketserver.py

示例7: test_ForkingTCPServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_ForkingTCPServer(self):
        with simple_subprocess(self):
            self.run_server(SocketServer.ForkingTCPServer,
                            SocketServer.StreamRequestHandler,
                            self.stream_examine) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_socketserver.py

示例8: test_UnixStreamServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_UnixStreamServer(self):
        self.run_server(SocketServer.UnixStreamServer,
                        SocketServer.StreamRequestHandler,
                        self.stream_examine) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_socketserver.py

示例9: test_ThreadingUnixStreamServer

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

示例10: test_InterruptServerSelectCall

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_InterruptServerSelectCall(self):
        with self.mocked_select_module() as mock_select:
            pid = self.run_server(SocketServer.TCPServer,
                                  SocketServer.StreamRequestHandler,
                                  self.stream_examine)
            # Make sure select was called again:
            self.assertGreater(mock_select.called, 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_socketserver.py

示例11: test_tcpserver_bind_leak

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_tcpserver_bind_leak(self):
        # Issue #22435: the server socket wouldn't be closed if bind()/listen()
        # failed.
        # Create many servers for which bind() will fail, to see if this result
        # in FD exhaustion.
        for i in range(1024):
            with self.assertRaises(OverflowError):
                SocketServer.TCPServer((HOST, -1),
                                       SocketServer.StreamRequestHandler) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_socketserver.py

示例12: test_issue5949

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_issue5949(self):

        class EOFHandler(SocketServer.StreamRequestHandler):
            def handle(self):
                # EOF without sending a complete welcome message.
                self.wfile.write('* OK')

        with self.reaped_server(EOFHandler) as server:
            self.assertRaises(imaplib.IMAP4.abort,
                              self.imap_class, *server.server_address) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_imaplib.py

示例13: test_ForkingTCPServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_ForkingTCPServer(self):
            with simple_subprocess(self):
                self.run_server(SocketServer.ForkingTCPServer,
                                SocketServer.StreamRequestHandler,
                                self.stream_examine) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:7,代码来源:test_socketserver.py

示例14: test_UnixStreamServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_UnixStreamServer(self):
            self.run_server(SocketServer.UnixStreamServer,
                            SocketServer.StreamRequestHandler,
                            self.stream_examine) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:6,代码来源:test_socketserver.py

示例15: test_ForkingUnixStreamServer

# 需要导入模块: import SocketServer [as 别名]
# 或者: from SocketServer import StreamRequestHandler [as 别名]
def test_ForkingUnixStreamServer(self):
                with simple_subprocess(self):
                    self.run_server(ForkingUnixStreamServer,
                                    SocketServer.StreamRequestHandler,
                                    self.stream_examine) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:7,代码来源:test_socketserver.py


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