Skip to content

Commit

Permalink
Call shutdown_asyncgens before loop closing (#2227)
Browse files Browse the repository at this point in the history
* Call shutdown_asyncgens before loop closing

* Check for shutdown_asyncgens existance

* Add changes
  • Loading branch information
asvetlov authored Aug 27, 2017
1 parent 796c9ea commit d7658d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ def run_app(app, *, host=None, port=None, path=None, sock=None,
finally:
loop.run_until_complete(app.cleanup())
if not user_supplied_loop:
if hasattr(loop, 'shutdown_asyncgens'):
loop.run_until_complete(loop.shutdown_asyncgens())
loop.close()


Expand Down
2 changes: 2 additions & 0 deletions aiohttp/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def run(self):
try:
self.loop.run_until_complete(self._runner)
finally:
if hasattr(self.loop, 'shutdown_asyncgens'):
self.loop.run_until_complete(self.loop.shutdown_asyncgens())
self.loop.close()

sys.exit(self.exit_code)
Expand Down
1 change: 1 addition & 0 deletions changes/2227.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Call `shutdown_asyncgens` before event loop closing on Python 3.6.

0 comments on commit d7658d4

Please sign in to comment.