當前位置: 首頁>>代碼示例>>Python>>正文


Python SimpleHandler.finish_response方法代碼示例

本文整理匯總了Python中wsgiref.handlers.SimpleHandler.finish_response方法的典型用法代碼示例。如果您正苦於以下問題:Python SimpleHandler.finish_response方法的具體用法?Python SimpleHandler.finish_response怎麽用?Python SimpleHandler.finish_response使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wsgiref.handlers.SimpleHandler的用法示例。


在下文中一共展示了SimpleHandler.finish_response方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: finish_response

# 需要導入模塊: from wsgiref.handlers import SimpleHandler [as 別名]
# 或者: from wsgiref.handlers.SimpleHandler import finish_response [as 別名]
    def finish_response(self):
        """
        Completes the response and performs the following tasks:

        - Remove the `'ws4py.socket'` and `'ws4py.websocket'`
          environ keys.
        - Attach the returned websocket, if any, to the WSGI server
          using its ``link_websocket_to_server`` method.
        """
        # force execution of the result iterator until first actual content
        rest = iter(self.result)
        first = list(itertools.islice(rest, 1))
        self.result = itertools.chain(first, rest)
        # now it's safe to look if environ was modified
        ws = None
        if self.environ:
            self.environ.pop('ws4py.socket', None)
            ws = self.environ.pop('ws4py.websocket', None)

        try:
            SimpleHandler.finish_response(self)
        except:
            if ws:
                ws.close(1011, reason='Something broke')
            raise
        else:
            if ws:
                self.request_handler.server.link_websocket_to_server(ws)
開發者ID:bozzzzo,項目名稱:quark,代碼行數:30,代碼來源:quark_ws4py_fixup.py

示例2: finish_response

# 需要導入模塊: from wsgiref.handlers import SimpleHandler [as 別名]
# 或者: from wsgiref.handlers.SimpleHandler import finish_response [as 別名]
    def finish_response(self):
        """
        Completes the response and performs the following tasks:

        - Remove the `'ws4py.socket'` and `'ws4py.websocket'`
          environ keys.
        - Attach the returned websocket, if any, to the WSGI server
          using its ``link_websocket_to_server`` method.
        """
        ws = None
        if self.environ:
            self.environ.pop('ws4py.socket', None)
            ws = self.environ.pop('ws4py.websocket', None)

        try:
            SimpleHandler.finish_response(self)
        except:
            if ws:
                ws.close(1011, reason='Something broke')
            raise
        else:
            if ws:
                self.request_handler.server.link_websocket_to_server(ws)
開發者ID:Anderson-Juhasc,項目名稱:bitex,代碼行數:25,代碼來源:wsgirefserver.py


注:本文中的wsgiref.handlers.SimpleHandler.finish_response方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。