'Attaches the given callback to the `Future`.
It will be invoked with the `Future` as its argument when the Future
has finished running and its result is available.  In Tornado
consider using `.IOLoop.add_future` instead of calling
`add_done_callback` directly.'

def add_done_callback(self, fn):

    if self._done:
        fn(self)
    else:
        self._callbacks.append(fn)
