Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Apply aiohttp's new ApplicationRunner API (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Feb 13, 2018
1 parent 27fbe50 commit 91d8d08
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions ai/backend/gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,24 @@ async def server_main(loop, pidx, _args):
await rlim_init(app)
await kernel_init(app)

web_handler = app.make_handler()
server = await loop.create_server(
web_handler,
host=str(app['config'].service_ip),
port=app['config'].service_port,
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(
runner,
str(app['config'].service_ip),
app['config'].service_port,
backlog=1024,
reuse_port=True,
ssl=app['sslctx'],
ssl_context=app['sslctx'],
)
await site.start()
log.info('started.')

try:
yield
finally:

log.info('shutting down...')
server.close()
await server.wait_closed()

await kernel_shutdown(app)
await rlim_shutdown(app)
Expand All @@ -236,8 +236,7 @@ async def server_main(loop, pidx, _args):
await event_shutdown(app)
await etcd_shutdown(app)

await app.shutdown()
await app.cleanup()
await runner.cleanup()


def gw_args(parser):
Expand Down

0 comments on commit 91d8d08

Please sign in to comment.