Skip to content

Commit 61ca4d2

Browse files
committed
call finish_connections() in web_srv.py
1 parent 7fa339e commit 61ca4d2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/web_srv.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ def init(loop):
5151
app.router.add_route('GET', '/hello/{name}', hello)
5252
app.router.add_route('GET', '/hello', hello)
5353

54-
srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', 8080)
54+
handler = app.make_handler()
55+
srv = yield from loop.create_server(handler, '127.0.0.1', 8080)
5556
print("Server started at http://127.0.0.1:8080")
56-
return srv
57+
return srv, handler
5758

5859
loop = asyncio.get_event_loop()
59-
loop.run_until_complete(init(loop))
60-
loop.run_forever()
60+
srv, handler = loop.run_until_complete(init(loop))
61+
try:
62+
loop.run_forever()
63+
except KeyboardInterrupt:
64+
loop.run_until_complete(handler.finish_connections())

0 commit comments

Comments
 (0)