DeprecationWarning: please use dns.resolver.Resolver.resolve()

2024/9/16 22:47:51

I am using resolver() as an alternative to socket() as I found that when multiple connections are made to different IPs it ends up stopping working. Anyway it returns a warning to me that I should use dns.resolver.Resolver.resolve () When changing it, it gives me an error:

TypeError: resolve() missing 2 required positional arguments: 'self' and 'qname'

This is the code:

        # my_resolver = dns.resolver.Resolver()my_resolver = dns.resolver.Resolver.resolve()answers = my_resolver.query(host, "A")answer_txt = my_resolver.query(host, "TXT")
Answer

faced the same problem

You should remove .resolve from my_resolver = dns.resolver.Resolver.resolve() and replace my_resolver.query() with my_resolver.resolve()

Example:

    my_resolver = dns.resolver.Resolver()answers = my_resolver.resolve(host, "A")answer_txt = my_resolver.resolve(host, "TXT")
https://en.xdnf.cn/q/72233.html

Related Q&A

python cannot find module when using ssh

Im using python on servers. When I run a python command which needs numpy module, if I do ssh <server name> <python command>that server will complain no module named numpy found.However, if…

Python sklearn installation windows

When trying to install Pythons sklearn package on Windows 10 using pip I am given an EnvironmentError that tells me there is no such file or directory of a specific file: ERROR: Could not install packa…

Python PSD layers?

I need to write a Python program for loading a PSD photoshop image, which has multiple layers and spit out png files (one for each layer). Can you do that in Python? Ive tried PIL, but there doesnt se…

Multiple inheritance: overridden methods containing super()-calls

With the file super5.py:class A:def m(self):print("m of A called")class B(A):def m(self):print("m of B called")super().m()class C(A):def m(self):print("m of C called")supe…

Specifying the output file name in Apache Spark

I have a MapReduce job that Im trying to migrate to PySpark. Is there any way of defining the name of the output file, rather than getting part-xxxxx?In MR, I was using the org.apache.hadoop.mapred.li…

How to plot two DataFrame on same graph for comparison

I have two DataFrames (trail1 and trail2) with the following columns: Genre, City, and Number Sold. Now I want to create a bar graph of both data sets for a side by side comparison of Genre vs. total N…

Babel doesnt recognize jinja2 extraction method for language support

Im adding language translation support to my project. The code is on Python and has jinja2 in the html files, and Javascript.Im trying to use Babel to do the translation, but it doesnt recognize the ex…

Automatically simplifying/refactoring Python code (e.g. for loops - list comprehension)? [closed]

Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.We don’t allow questi…

Knowing the number of iterations needed for convergence in SVR scikit-learn

I am trying to optimize an SVR model and facing a problem because of overfitting, to overcome this I have tried to decrease the number of iterations instead of leaving it until convergence.To compare …

Why is `NaN` considered smaller than `-np.inf` in numpy?

What is the reason that NaNs are considered less than -np.inf in any comparisons involving np.min or np.argmin?import numpy as np In [73]: m = np.array([np.nan, 1., 0., -np.inf]) In [74]: n = np.array…