def asFuture(self, loop):
        """
        Adapt a L{Deferred} into a L{asyncio.Future} which is bound to C{loop}.

        @note: converting a L{Deferred} to an L{asyncio.Future} consumes both
            its result and its errors, so this method implicitly converts
            C{self} into a L{Deferred} firing with L{None}, regardless of what
            its result previously would have been.

        @since: Twisted 17.5.0

        @param loop: The asyncio event loop to bind the L{asyncio.Future} to.
        @type loop: L{asyncio.AbstractEventLoop} or similar

        @param deferred: The Deferred to adapt.
        @type deferred: L{Deferred}

        @return: A Future which will fire when the Deferred fires.
        @rtype: L{asyncio.Future}
        """
        try:
            createFuture = loop.create_future
        except AttributeError:
            from asyncio import Future
            def createFuture():
                return Future(loop=loop)
        future = createFuture()
        def checkCancel(futureAgain):
            if futureAgain.cancelled():
                self.cancel()
        def maybeFail(failure):
            if not future.cancelled():
                future.set_exception(failure.value)
        def maybeSucceed(result):
            if not future.cancelled():
                future.set_result(result)
        self.addCallbacks(maybeSucceed, maybeFail)
        future.add_done_callback(checkCancel)
        return future

        Adapt a L{Deferred} into a L{asyncio.Future} which is bound to C{loop}.

        @note: converting a L{Deferred} to an L{asyncio.Future} consumes both
            its result and its errors, so this method implicitly converts
            C{self} into a L{Deferred} firing with L{None}, regardless of what
            its result previously would have been.

        @since: Twisted 17.5.0

        @param loop: The asyncio event loop to bind the L{asyncio.Future} to.
        @type loop: L{asyncio.AbstractEventLoop} or similar

        @param deferred: The Deferred to adapt.
        @type deferred: L{Deferred}

        @return: A Future which will fire when the Deferred fires.
        @rtype: L{asyncio.Future}
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/defer.py