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


Python WSGIServer.handle_request方法代码示例

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


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

示例1: _run_wsgi

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
 def _run_wsgi(self, addr, port, wsgi_handler):
     server_address = (addr, port)
     httpd = WSGIServer(server_address, WSGIRequestHandler)
     httpd.set_app(wsgi_handler)
     #httpd.serve_forever()
     while not self.stop_requested:
         httpd.handle_request()        
开发者ID:qivhou,项目名称:WIP-Viewer,代码行数:9,代码来源:DjangoService.py

示例2: run

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
    def run(self):
        self.lock.acquire()
        pidfile = os.path.join(tempfile.gettempdir(), 'lettuce-django.pid')
        if os.path.exists(pidfile):
            pid = int(open(pidfile).read())
            try:
                os.kill(pid, 9)

            except OSError:
                pass

            finally:
                os.unlink(pidfile)

        open(pidfile, 'w').write(unicode(os.getpid()))

        bound = False
        max_port = 65535

        connector = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        while not bound or self.port < max_port:
            try:
                connector.connect((self.address, self.port))
                self.port += 1

            except socket.error:
                bound = True
                break

        if bound:
            try:
                server_address = (self.address, self.port)
                httpd = WSGIServer(server_address, MutedRequestHandler)
                bound = True
            except WSGIServerException:
                bound = False

        if not bound:
            raise LettuceServerException(
                "the port %d already being used, could not start " \
                "django's builtin server on it" % self.port
            )


        handler = StopabbleHandler(WSGIHandler())
        if 'django.contrib.admin' in settings.INSTALLED_APPS:
            admin_media_path = ''
            handler = AdminMediaHandler(handler, admin_media_path)
            print "Preparing to server django's admin site static files..."

        httpd.set_app(handler)

        global keep_running
        while keep_running:
            call_hook('before', 'handle_request', httpd, self)
            httpd.handle_request()
            call_hook('after', 'handle_request', httpd, self)
            if self.lock.locked():
                self.lock.release()
开发者ID:camd,项目名称:lettuce,代码行数:61,代码来源:server.py

示例3: run

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
    def run(self):
        self.lock.acquire()
        pidfile = os.path.join(tempfile.gettempdir(), 'lettuce-django.pid')
        if os.path.exists(pidfile):
            pid = int(open(pidfile).read())
            try:
                os.kill(pid, 9)

            except OSError:
                pass

            finally:
                os.unlink(pidfile)

        open(pidfile, 'w').write(unicode(os.getpid()))

        connector = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:
            s = connector.connect((self.address, self.port))
            self.lock.release()
            os.kill(os.getpid(), 9)
        except socket.error:
            pass

        finally:
            self.lock.release()

        try:
            server_address = (self.address, self.port)
            httpd = WSGIServer(server_address, MutedRequestHandler)
        except WSGIServerException:
            raise LettuceServerException(
                "the port %d already being used, could not start " \
                "django's builtin server on it" % self.port,
            )

        handler = WSGIHandler()
        if self.should_serve_admin_media():
            admin_media_path = ''
            handler = AdminMediaHandler(handler, admin_media_path)

        if self.should_serve_static_files():
            handler = StaticFilesHandler(handler)

        httpd.set_app(handler)

        global keep_running
        while keep_running:
            call_hook('before', 'handle_request', httpd, self)
            httpd.handle_request()
            call_hook('after', 'handle_request', httpd, self)
            try:
                self.lock.release()
            except ValueError:
                pass
开发者ID:UjeenM,项目名称:lettuce,代码行数:58,代码来源:server.py

示例4: run

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
 def run(self):
     try:
         handler = AdminMediaHandler(WSGIHandler())
         server_address = (config.HOST, config.PORT)
         httpd = WSGIServer(server_address, SilentWSGIRequestHandler)
         httpd.set_app(handler)
         while self.running.isSet():
             httpd.handle_request()
         httpd.server_close()
     except WSGIServerException, e:
         pass
开发者ID:fgallina,项目名称:django-seltest,代码行数:13,代码来源:testrunners.py

示例5: run

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
    def run(self):
        self.lock.acquire()
        pidfile = os.path.join(tempfile.gettempdir(), 'lettuce-django.pid')

        if os.path.exists(pidfile):
            pid = int(open(pidfile).read())
            try:
                os.kill(pid, 9)

            except OSError:
                pass

            finally:
                os.unlink(pidfile)

        open(pidfile, 'w').write(unicode(os.getpid()))

        bound = False
        max_port = 65535
        while not bound or self.port > max_port:
            try:
                server_address = (self.address, self.port)
                httpd = WSGIServer(server_address, MutedRequestHandler)
                bound = True
            except WSGIServerException:
                self.port += 1

        if not bound:
            raise LettuceServerException(
                "the port %d already being used, could not start " \
                "django's builtin server on it" % self.port
            )

        httpd.set_app(StopabbleHandler(WSGIHandler()))
        self.lock.release()

        global keep_running
        while keep_running:
            httpd.handle_request()
开发者ID:emanuell,项目名称:lettuce,代码行数:41,代码来源:server.py

示例6: handle_request

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
 def handle_request(self, timeout=1.0):
     reads, writes, errors = (self, ), (), ()
     reads, writes, errors = select.select(reads, writes, errors, timeout)
     if reads:
         WSGIServer.handle_request(self)
开发者ID:Agana,项目名称:rapidsms,代码行数:7,代码来源:http.py

示例7: run

# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import handle_request [as 别名]
    def run(self):
        self.lock.acquire()
        pidfile = os.path.join(tempfile.gettempdir(), "lettuce-django.pid")
        if os.path.exists(pidfile):
            pid = int(open(pidfile).read())
            try:
                os.kill(pid, 9)

            except OSError:
                pass

            finally:
                os.unlink(pidfile)

        open(pidfile, "w").write(unicode(os.getpid()))

        bound = False
        max_port = 65535

        connector = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        while not bound or self.port < max_port:
            try:
                connector.connect((self.address, self.port))
                self.port += 1

            except socket.error:
                bound = True
                break

        if bound:
            try:
                server_address = (self.address, self.port)
                httpd = WSGIServer(server_address, MutedRequestHandler)
                bound = True
            except WSGIServerException:
                bound = False

        if not bound:
            raise LettuceServerException(
                "the port %d already being used, could not start " "django's builtin server on it" % self.port
            )

        handler = WSGIHandler()
        if self.should_serve_admin_media():
            admin_media_path = ""
            handler = AdminMediaHandler(handler, admin_media_path)

        if self.should_serve_static_files():
            handler = StaticFilesHandler(handler)

        httpd.set_app(handler)

        global keep_running
        while keep_running:
            call_hook("before", "handle_request", httpd, self)
            httpd.handle_request()
            call_hook("after", "handle_request", httpd, self)
            try:
                self.lock.release()
            except ValueError:
                pass
开发者ID:igorgue,项目名称:lettuce,代码行数:63,代码来源:server.py


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