1
我想了解如何使這個example採取aiohttp.web.Application
實例,以便它可以使用這個模式:使用web.Application多處理
def handler1(request):
...
def handler2(request):
...
app = web.Application()
app.router.add_route('GET', '/one', handler1)
app.router.add_route('GET', '/two', handler2)
是什麼讓我的生活困難的是,我已經能夠將我的應用程序實例提交給ChildProcess。 初始化但無法弄清楚如何修改啓動方式(我只保留了我需要幫助修改部分):
class ChildProcess:
def __init__(self, up_read, down_write, app, args, sock):
...
self.app = app
...
def start(self):
...
# how to leverage the app.router here????
# these few lines like aiohttp.web.run_app(app) code
# there must be a way to make this work together
f = loop.create_server(
lambda: HttpRequestHandler(debug=True, keep_alive=75),
sock=self.sock)
srv = loop.run_until_complete(f)