def _query(self, *args):
        """
        Get a new L{DNSDatagramProtocol} instance from L{_connectedProtocol},
        issue a query to it using C{*args}, and arrange for it to be
        disconnected from its transport after the query completes.

        @param *args: Positional arguments to be passed to
            L{DNSDatagramProtocol.query}.

        @return: A L{Deferred} which will be called back with the result of the
            query.
        """
        if isIPv6Address(args[0][0]):
            protocol = self._connectedProtocol(interface='::')
        else:
            protocol = self._connectedProtocol()
        d = protocol.query(*args)
        def cbQueried(result):
            protocol.transport.stopListening()
            return result
        d.addBoth(cbQueried)
        return d

        Get a new L{DNSDatagramProtocol} instance from L{_connectedProtocol},
        issue a query to it using C{*args}, and arrange for it to be
        disconnected from its transport after the query completes.

        @param *args: Positional arguments to be passed to
            L{DNSDatagramProtocol.query}.

        @return: A L{Deferred} which will be called back with the result of the
            query.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/names/client.py