當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。