本文整理匯總了Python中aiohttp.wsgi.WSGIServerHttpProtocol方法的典型用法代碼示例。如果您正苦於以下問題:Python wsgi.WSGIServerHttpProtocol方法的具體用法?Python wsgi.WSGIServerHttpProtocol怎麽用?Python wsgi.WSGIServerHttpProtocol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類aiohttp.wsgi
的用法示例。
在下文中一共展示了wsgi.WSGIServerHttpProtocol方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from aiohttp import wsgi [as 別名]
# 或者: from aiohttp.wsgi import WSGIServerHttpProtocol [as 別名]
def run(self, handler):
import asyncio
from aiohttp.wsgi import WSGIServerHttpProtocol
self.loop = self.get_event_loop()
asyncio.set_event_loop(self.loop)
protocol_factory = lambda: WSGIServerHttpProtocol(
handler,
readpayload=True,
debug=(not self.quiet))
self.loop.run_until_complete(self.loop.create_server(protocol_factory,
self.host,
self.port))
if 'BOTTLE_CHILD' in os.environ:
import signal
signal.signal(signal.SIGINT, lambda s, f: self.loop.stop())
try:
self.loop.run_forever()
except KeyboardInterrupt:
self.loop.stop()
示例2: run
# 需要導入模塊: from aiohttp import wsgi [as 別名]
# 或者: from aiohttp.wsgi import WSGIServerHttpProtocol [as 別名]
def run(self, handler):
import asyncio
from aiohttp.wsgi import WSGIServerHttpProtocol
self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)
protocol_factory = lambda: WSGIServerHttpProtocol(
handler,
readpayload=True,
debug=(not self.quiet))
self.loop.run_until_complete(self.loop.create_server(protocol_factory,
self.host,
self.port))
if 'BOTTLE_CHILD' in os.environ:
import signal
signal.signal(signal.SIGINT, lambda s, f: self.loop.stop())
try:
self.loop.run_forever()
except KeyboardInterrupt:
self.loop.stop()
示例3: factory
# 需要導入模塊: from aiohttp import wsgi [as 別名]
# 或者: from aiohttp.wsgi import WSGIServerHttpProtocol [as 別名]
def factory(self, wsgi, addr):
# are we in debug level
is_debug = self.log.loglevel == logging.DEBUG
proto = WSGIServerHttpProtocol(
wsgi, readpayload=True,
loop=self.loop,
log=self.log,
debug=is_debug,
keep_alive=self.cfg.keepalive,
access_log=self.log.access_log,
access_log_format=self.cfg.access_log_format)
return self.wrap_protocol(proto)
示例4: __call__
# 需要導入模塊: from aiohttp import wsgi [as 別名]
# 或者: from aiohttp.wsgi import WSGIServerHttpProtocol [as 別名]
def __call__(self):
return WSGIServerHttpProtocol(
self.handler, readpayload=True,
loop=self._loop,
logger=self.worker.log,
debug=self.worker.log.loglevel == logging.DEBUG,
keep_alive=self.worker.cfg.keepalive,
access_log=self.worker.log.access_log,
access_log_format=self.access_log_format)