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


Python http.wsgi方法代码示例

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


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

示例1: patch_sendfile

# 需要导入模块: from gunicorn import http [as 别名]
# 或者: from gunicorn.http import wsgi [as 别名]
def patch_sendfile():
    from gunicorn.http import wsgi

    if o_sendfile is not None:
        setattr(wsgi, "sendfile", _eventlet_sendfile) 
开发者ID:RoseOu,项目名称:flasky,代码行数:7,代码来源:geventlet.py

示例2: patch_sendfile

# 需要导入模块: from gunicorn import http [as 别名]
# 或者: from gunicorn.http import wsgi [as 别名]
def patch_sendfile():
    from gunicorn.http import wsgi

    if o_sendfile is not None:
        setattr(wsgi, "sendfile", _gevent_sendfile) 
开发者ID:RoseOu,项目名称:flasky,代码行数:7,代码来源:ggevent.py

示例3: run

# 需要导入模块: from gunicorn import http [as 别名]
# 或者: from gunicorn.http import wsgi [as 别名]
def run(self):
        servers = []
        ssl_args = {}

        if self.cfg.is_ssl:
            ssl_args = dict(server_side=True, **self.cfg.ssl_options)

        for s in self.sockets:
            s.setblocking(1)
            pool = Pool(self.worker_connections)
            if self.server_class is not None:
                environ = base_environ(self.cfg)
                environ.update({
                    "wsgi.multithread": True,
                    "SERVER_SOFTWARE": VERSION,
                })
                server = self.server_class(
                    s, application=self.wsgi, spawn=pool, log=self.log,
                    handler_class=self.wsgi_handler, environ=environ,
                    **ssl_args)
            else:
                hfun = partial(self.handle, s)
                server = StreamServer(s, handle=hfun, spawn=pool, **ssl_args)

            server.start()
            servers.append(server)

        while self.alive:
            self.notify()
            gevent.sleep(1.0)

        try:
            # Stop accepting requests
            for server in servers:
                if hasattr(server, 'close'):  # gevent 1.0
                    server.close()
                if hasattr(server, 'kill'):  # gevent < 1.0
                    server.kill()

            # Handle current requests until graceful_timeout
            ts = time.time()
            while time.time() - ts <= self.cfg.graceful_timeout:
                accepting = 0
                for server in servers:
                    if server.pool.free_count() != server.pool.size:
                        accepting += 1

                # if no server is accepting a connection, we can exit
                if not accepting:
                    return

                self.notify()
                gevent.sleep(1.0)

            # Force kill all active the handlers
            self.log.warning("Worker graceful timeout (pid:%s)" % self.pid)
            [server.stop(timeout=1) for server in servers]
        except:
            pass 
开发者ID:yelongyu,项目名称:chihu,代码行数:61,代码来源:ggevent.py


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