'Add a callback to the set of callbacks to be called
unconditionally by the :term:`router` at the very end of
request processing.
``callback`` is a callable which accepts a single positional
parameter: ``request``.  For example:
.. code-block:: python
:linenos:
import transaction
def commit_callback(request):
\'\'\'commit or abort the transaction associated with request\'\'\'
if request.exception is not None:
transaction.abort()
else:
transaction.commit()
request.add_finished_callback(commit_callback)
Finished callbacks are called in the order they\'re added (
first- to most-recently- added).  Finished callbacks (unlike
response callbacks) are *always* called, even if an exception
happens in application code that prevents a response from
being generated.
The set of finished callbacks associated with a request are
called *very late* in the processing of that request; they are
essentially the last thing called by the :term:`router`. They
are called after response processing has already occurred in a
top-level ``finally:`` block within the router request
processing code.  As a result, mutations performed to the
``request`` provided to a finished callback will have no
meaningful effect, because response processing will have
already occurred, and the request\'s scope will expire almost
immediately after all finished callbacks have been processed.
Errors raised by finished callbacks are not handled specially.
They will be propagated to the caller of the :app:`Pyramid`
router application.
.. seealso::
See also :ref:`using_finished_callbacks`.'

def add_finished_callback(self, callback):

    self.finished_callbacks.append(callback)
