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