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


Python basehttp.WSGIServer方法代碼示例

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


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

示例1: _create_server

# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import WSGIServer [as 別名]
def _create_server(self):
        return WSGIServer((self.host, self.port), QuietWSGIRequestHandler, allow_reuse_address=False) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:4,代碼來源:testcases.py

示例2: _create_server

# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import WSGIServer [as 別名]
def _create_server(self, port):
        return WSGIServer((self.host, port), QuietWSGIRequestHandler) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:4,代碼來源:testcases.py

示例3: run

# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import WSGIServer [as 別名]
def run(self, *args, **options):
        threading = options.get("use_threading", False)
        if threading:
            # This is a simple backport from Django's future
            # version to support threading.
            class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
                pass

            # Monkey patch basehttp.WSGIServer.
            setattr(basehttp, "WSGIServer", ThreadedWSGIServer)

        start_up()
        return super().run(*args, **options) 
開發者ID:maas,項目名稱:maas,代碼行數:15,代碼來源:runserver.py

示例4: run

# 需要導入模塊: from django.core.servers import basehttp [as 別名]
# 或者: from django.core.servers.basehttp import WSGIServer [as 別名]
def run(self):
        """
        Sets up the live server and databases, and then loops over handling
        http requests.
        """
        if self.connections_override:
            # Override this thread's database connections with the ones
            # provided by the main thread.
            for alias, conn in self.connections_override.items():
                connections[alias] = conn
        try:
            # Create the handler for serving static and media files
            handler = self.static_handler(_MediaFilesHandler(WSGIHandler()))

            # Go through the list of possible ports, hoping that we can find
            # one that is free to use for the WSGI server.
            for index, port in enumerate(self.possible_ports):
                try:
                    self.httpd = WSGIServer(
                        (self.host, port), QuietWSGIRequestHandler)
                except socket.error as e:
                    if (index + 1 < len(self.possible_ports) and
                            e.errno == errno.EADDRINUSE):
                        # This port is already in use, so we go on and try with
                        # the next one in the list.
                        continue
                    else:
                        # Either none of the given ports are free or the error
                        # is something else than "Address already in use". So
                        # we let that error bubble up to the main thread.
                        raise
                else:
                    # A free port was found.
                    self.port = port
                    break

            self.httpd.set_app(handler)
            self.is_ready.set()
            self.httpd.serve_forever()
        except Exception as e:
            self.error = e
            self.is_ready.set() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:44,代碼來源:testcases.py


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