Skip to content

Commit

Permalink
drop Application.finish() and Application.register_on_finish() #1602
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Kim committed Feb 8, 2017
1 parent 5ed89d1 commit fc126aa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 53 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ CHANGES

- Dropped: Adding `sub app` via `app.router.add_subapp()` is deprecated
use `app.add_subapp()` instead #1592

- Dropped: `Application.finish()` and `Application.register_on_finish()` #1602
13 changes: 0 additions & 13 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,6 @@ def cleanup(self):
"""
yield from self.on_cleanup.send(self)

@asyncio.coroutine
def finish(self):
"""Finalize an application.
Deprecated alias for .cleanup()
"""
warnings.warn("Use .cleanup() instead", DeprecationWarning)
yield from self.cleanup()

def register_on_finish(self, func, *args, **kwargs):
warnings.warn("Use .on_cleanup.append() instead", DeprecationWarning)
self.on_cleanup.append(lambda app: func(app, *args, **kwargs))

def _make_request(self, message, payload, protocol,
_cls=web_reqrep.Request):
return _cls(
Expand Down
27 changes: 2 additions & 25 deletions docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ duplicated like one using :meth:`Application.copy`.
.. coroutinemethod:: shutdown()

A :ref:`coroutine<coroutine>` that should be called on
server stopping but before :meth:`finish()`.
server stopping but before :meth:`cleanup()`.

The purpose of the method is calling :attr:`on_shutdown` signal
handlers.
Expand All @@ -1368,29 +1368,6 @@ duplicated like one using :meth:`Application.copy`.
The purpose of the method is calling :attr:`on_cleanup` signal
handlers.

.. coroutinemethod:: finish()

A deprecated alias for :meth:`cleanup`.

.. deprecated:: 0.21

.. method:: register_on_finish(self, func, *args, **kwargs):

Register *func* as a function to be executed at termination.
Any optional arguments that are to be passed to *func* must be
passed as arguments to :meth:`register_on_finish`. It is possible to
register the same function and arguments more than once.

During the call of :meth:`finish` all functions registered are called in
last in, first out order.

*func* may be either regular function or :ref:`coroutine<coroutine>`,
:meth:`finish` will un-yield (`await`) the later.

.. deprecated:: 0.21

Use :attr:`on_cleanup` instead: ``app.on_cleanup.append(handler)``.

.. note::

Application object has :attr:`router` attribute but has no
Expand Down Expand Up @@ -1935,7 +1912,7 @@ Resource classes hierarchy::
.. class:: PrefixedSubAppResource

A resource for serving nested applications. The class instance is
returned by :class:`~aiohttp.web.UrlDispatcher.add_subapp` call.
returned by :class:`~aiohttp.web.Application.add_subapp` call.

.. versionadded:: 1.1

Expand Down
15 changes: 0 additions & 15 deletions tests/test_web_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ def cb(app):
assert 123 == fut.result()


@asyncio.coroutine
def test_app_register_and_finish_are_deprecated(loop):
app = web.Application(loop=loop)
cb1 = mock.Mock()
cb2 = mock.Mock()
with pytest.warns(DeprecationWarning):
app.register_on_finish(cb1, 1, b=2)
with pytest.warns(DeprecationWarning):
app.register_on_finish(cb2, 2, c=3)
with pytest.warns(DeprecationWarning):
yield from app.finish()
cb1.assert_called_once_with(app, 1, b=2)
cb2.assert_called_once_with(app, 2, c=3)


def test_non_default_router(loop):
router = mock.Mock(spec=AbstractRouter)
app = web.Application(loop=loop, router=router)
Expand Down

0 comments on commit fc126aa

Please sign in to comment.